diff --git a/.github/scripts/Configure-AppxManifest.ps1 b/.github/scripts/Configure-AppxManifest.ps1 index 055a3dfb0fd2..abca500cd1c3 100644 --- a/.github/scripts/Configure-AppxManifest.ps1 +++ b/.github/scripts/Configure-AppxManifest.ps1 @@ -11,7 +11,17 @@ param( [string]$SecretGitHubOAuthClientId = "" ) +# Load Package.appxmanifest [xml]$xmlDoc = Get-Content $PackageManifestPath + +# Add namespaces +$nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable) +$nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10") +$nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities") +$nsmgr.AddNamespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10") +$nsmgr.AddNamespace("uap5", "http://schemas.microsoft.com/appx/manifest/uap/windows10/5") + +# Update the publisher $xmlDoc.Package.Identity.Publisher = $Publisher if ($Branch -eq "Preview") @@ -21,6 +31,14 @@ if ($Branch -eq "Preview") $xmlDoc.Package.Properties.DisplayName="Files - Preview" $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview" $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files - Preview" + + # Update app protocol and execution alias + $ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']", $nsmgr) + $ap.Attributes["Name"]="files-pre"; + $aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr) + $aea.Attributes["Alias"]="files-pre.exe"; + + # Save modified Package.appxmanifest $xmlDoc.Save($PackageManifestPath) Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process ` @@ -28,6 +46,12 @@ if ($Branch -eq "Preview") (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | ` Set-Content $_ -NoNewline ` } + + Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` + { ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-pre" }) | ` + Set-Content $_ -NoNewline ` + } } elseif ($Branch -eq "Stable") { @@ -36,6 +60,14 @@ elseif ($Branch -eq "Stable") $xmlDoc.Package.Properties.DisplayName="Files" $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files" $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files" + + # Update app protocol and execution alias + $ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']", $nsmgr) + $ap.Attributes["Name"]="files"; + $aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr) + $aea.Attributes["Alias"]="files.exe"; + + # Save modified Package.appxmanifest $xmlDoc.Save($PackageManifestPath) Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process ` @@ -43,6 +75,12 @@ elseif ($Branch -eq "Stable") (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | ` Set-Content $_ -NoNewline ` } + + Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` + { ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files" }) | ` + Set-Content $_ -NoNewline ` + } } elseif ($Branch -eq "Store") { @@ -53,11 +91,16 @@ elseif ($Branch -eq "Store") $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files" # Remove an capability that is used for the sideload - $nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable) - $nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10") - $nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities") $pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr) $xmlDoc.Package.Capabilities.RemoveChild($pm) + + # Update app protocol and execution alias + $ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']", $nsmgr) + $ap.Attributes["Name"]="files"; + $aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr) + $aea.Attributes["Alias"]="files.exe"; + + # Save modified Package.appxmanifest $xmlDoc.Save($PackageManifestPath) Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process ` @@ -65,6 +108,12 @@ elseif ($Branch -eq "Store") (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | ` Set-Content $_ -NoNewline ` } + + Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process ` + { ` + (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files" }) | ` + Set-Content $_ -NoNewline ` + } } Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process ` diff --git a/src/Files.App (Package)/Package.appxmanifest b/src/Files.App (Package)/Package.appxmanifest index 36a4c2852eca..34c873984c1d 100644 --- a/src/Files.App (Package)/Package.appxmanifest +++ b/src/Files.App (Package)/Package.appxmanifest @@ -119,12 +119,14 @@ - + + - + + diff --git a/src/Files.App.Launcher/FilesLauncher.cpp b/src/Files.App.Launcher/FilesLauncher.cpp index 4873f8ee563a..f766e4aa842b 100644 --- a/src/Files.App.Launcher/FilesLauncher.cpp +++ b/src/Files.App.Launcher/FilesLauncher.cpp @@ -65,7 +65,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine LocalFree(szArglist); WCHAR szBuf[MAX_PATH]; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1); std::wcout << szBuf << std::endl; if (_waccess(szBuf, 0) == -1) { @@ -172,7 +172,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine swprintf(args, _countof(args) - 1, L"\"%s\" -select \"%s\"", szBuf, item.c_str()); } - std::wstring uriWithArgs = L"files-uwp:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); + std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); std::wcout << L"Invoking: " << args << L" = " << uriWithArgs << std::endl; @@ -187,7 +187,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine { std::wcout << L"Protocol error: " << GetLastError() << std::endl; - //ShExecInfo.lpFile = L"files.exe"; + //ShExecInfo.lpFile = L"files-dev.exe"; //ShExecInfo.lpParameters = args; //if (!ShellExecuteEx(&ShExecInfo)) //{ @@ -202,13 +202,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine SHELLEXECUTEINFO ShExecInfo = { 0 }; ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfo.fMask = SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI; - ShExecInfo.lpFile = L"files-uwp:"; + ShExecInfo.lpFile = L"files-dev:"; ShExecInfo.nShow = SW_SHOW; if (!ShellExecuteEx(&ShExecInfo)) { std::wcout << L"Protocol error: " << GetLastError() << std::endl; - //ShExecInfo.lpFile = L"files.exe"; + //ShExecInfo.lpFile = L"files-dev.exe"; //if (!ShellExecuteEx(&ShExecInfo)) //{ //std::wcout << L"Command line error: " << GetLastError() << std::endl; diff --git a/src/Files.App.OpenDialog/FilesOpenDialog.cpp b/src/Files.App.OpenDialog/FilesOpenDialog.cpp index f1dec80b6568..261f68ca9468 100644 --- a/src/Files.App.OpenDialog/FilesOpenDialog.cpp +++ b/src/Files.App.OpenDialog/FilesOpenDialog.cpp @@ -162,7 +162,7 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner) PWSTR pszPath = NULL; WCHAR szBuf[MAX_PATH]; TCHAR args[1024] = { 0 }; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1); HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); @@ -177,7 +177,7 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner) swprintf(args, _countof(args) - 1, L"\"%s\" -outputpath \"%s\"", szBuf, _outputPath.c_str()); } - std::wstring uriWithArgs = L"files-uwp:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); + std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); ShExecInfo.lpFile = uriWithArgs.c_str(); ShExecInfo.nShow = SW_SHOW; ShellExecuteEx(&ShExecInfo); diff --git a/src/Files.App.SaveDialog/FilesSaveDialog.cpp b/src/Files.App.SaveDialog/FilesSaveDialog.cpp index b17d018e78f9..49dddc8fcfb7 100644 --- a/src/Files.App.SaveDialog/FilesSaveDialog.cpp +++ b/src/Files.App.SaveDialog/FilesSaveDialog.cpp @@ -438,7 +438,7 @@ HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner) PWSTR pszPath = NULL; WCHAR szBuf[MAX_PATH]; TCHAR args[1024] = { 0 }; - ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1); + ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1); HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG")); @@ -460,7 +460,7 @@ HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner) swprintf(args, _countof(args) - 1, L"\"%s\" -outputpath \"%s\"", szBuf, _outputPath.c_str()); } - std::wstring uriWithArgs = L"files-uwp:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); + std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args)); ShExecInfo.lpFile = uriWithArgs.c_str(); ShExecInfo.nShow = SW_SHOW; ShellExecuteEx(&ShExecInfo); diff --git a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs index fbd023ed5c58..83da54c7a8df 100644 --- a/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs +++ b/src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs @@ -50,7 +50,7 @@ public virtual async Task ExecuteAsync(object? parameter = null) foreach (ListedItem listedItem in items) { var selectedItemPath = (listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath; - var folderUri = new Uri($"files-uwp:?folder={@selectedItemPath}"); + var folderUri = new Uri($"files-dev:?folder={@selectedItemPath}"); await Launcher.LaunchUriAsync(folderUri); } diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs index 8c2926268ea5..062a74a9edd1 100644 --- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs +++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs @@ -340,7 +340,7 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti // Try to re-launch and start over MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () => { - await Launcher.LaunchUriAsync(new Uri("files-uwp:")); + await Launcher.LaunchUriAsync(new Uri("files-dev:")); }) .Wait(100); } diff --git a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs index e441f6688dc9..9cc563d104e3 100644 --- a/src/Files.App/Helpers/Navigation/NavigationHelpers.cs +++ b/src/Files.App/Helpers/Navigation/NavigationHelpers.cs @@ -286,14 +286,14 @@ public static Task OpenPathInNewWindowAsync(string? path) if (string.IsNullOrWhiteSpace(path)) return Task.FromResult(false); - var folderUri = new Uri($"files-uwp:?folder={Uri.EscapeDataString(path)}"); + var folderUri = new Uri($"files-dev:?folder={Uri.EscapeDataString(path)}"); return Launcher.LaunchUriAsync(folderUri).AsTask(); } public static Task OpenTabInNewWindowAsync(string tabArgs) { - var folderUri = new Uri($"files-uwp:?tab={Uri.EscapeDataString(tabArgs)}"); + var folderUri = new Uri($"files-dev:?tab={Uri.EscapeDataString(tabArgs)}"); return Launcher.LaunchUriAsync(folderUri).AsTask(); } @@ -307,8 +307,7 @@ public static void OpenInSecondaryPane(IShellPage associatedInstance, ListedItem public static Task LaunchNewWindowAsync() { - var filesUWPUri = new Uri("files-uwp:?window="); - return Launcher.LaunchUriAsync(filesUWPUri).AsTask(); + return Launcher.LaunchUriAsync(new Uri("files-dev:?window=")).AsTask(); } public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, bool openViaApplicationPicker = false) diff --git a/src/Files.App/MainWindow.xaml.cs b/src/Files.App/MainWindow.xaml.cs index 34f4aed86bb6..da4d1bd1247f 100644 --- a/src/Files.App/MainWindow.xaml.cs +++ b/src/Files.App/MainWindow.xaml.cs @@ -52,8 +52,8 @@ public async Task InitializeApplicationAsync(object activatedEventArgs) { case ILaunchActivatedEventArgs launchArgs: if (launchArgs.Arguments is not null && - (CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files.exe", StringComparison.OrdinalIgnoreCase) - || CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files", StringComparison.OrdinalIgnoreCase))) + (CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files-dev.exe", StringComparison.OrdinalIgnoreCase) + || CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files-dev", StringComparison.OrdinalIgnoreCase))) { // WINUI3: When launching from commandline the argument is not ICommandLineActivatedEventArgs (#10370) var ppm = CommandLineParser.ParseUntrustedCommands(launchArgs.Arguments); @@ -82,7 +82,7 @@ public async Task InitializeApplicationAsync(object activatedEventArgs) break; case IProtocolActivatedEventArgs eventArgs: - if (eventArgs.Uri.AbsoluteUri == "files-uwp:") + if (eventArgs.Uri.AbsoluteUri == "files-dev:") { rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo()); diff --git a/src/Files.App/Program.cs b/src/Files.App/Program.cs index a0239827dc27..d78c950d08f6 100644 --- a/src/Files.App/Program.cs +++ b/src/Files.App/Program.cs @@ -220,8 +220,8 @@ static bool ProcessPathPredicate(Process p) var cmdLaunchArgs = activatedArgs.Data is ILaunchActivatedEventArgs launchArgs && launchArgs.Arguments is not null && CommandLineParser.SplitArguments(launchArgs.Arguments, true).FirstOrDefault() is string arg0 && - (arg0.EndsWith($"files.exe", StringComparison.OrdinalIgnoreCase) || - arg0.EndsWith($"files", StringComparison.OrdinalIgnoreCase)) ? launchArgs.Arguments : null; + (arg0.EndsWith($"files-dev.exe", StringComparison.OrdinalIgnoreCase) || + arg0.EndsWith($"files-dev", StringComparison.OrdinalIgnoreCase)) ? launchArgs.Arguments : null; var cmdProtocolArgs = activatedArgs.Data is IProtocolActivatedEventArgs protocolArgs && protocolArgs.Uri.Query.TrimStart('?').Split('=') is string[] parsedArgs && parsedArgs.Length == 2 && parsedArgs[0] == "cmd" ? Uri.UnescapeDataString(parsedArgs[1]) : null; diff --git a/src/Files.App/Utils/Taskbar/SystemTrayIcon.cs b/src/Files.App/Utils/Taskbar/SystemTrayIcon.cs index 9ddc38f1f279..cbf803977755 100644 --- a/src/Files.App/Utils/Taskbar/SystemTrayIcon.cs +++ b/src/Files.App/Utils/Taskbar/SystemTrayIcon.cs @@ -27,7 +27,19 @@ public sealed class SystemTrayIcon : IDisposable // Fields - private readonly static Guid _trayIconGuid = new("684F2832-AC2B-4630-98C2-73D6AEBD46B7"); + private readonly static Guid _trayIconGuid = new( +#if DEBUG + "e6fc16c1-e6e2-40a2-9c4e-1bf3b54684ad" +#elif PREVIEW + "8bd7e317-ee80-405e-8c90-f4d9866ff9bc" +#elif STABLE + "96b3455b-16bf-454e-ada5-191ba32f2f8e" +#elif STORE + "01966f57-00cf-471f-b2d5-55f227e0dfe6" +#else + "e77abbd8-8721-4d50-a4d2-743d28cdc37b" +#endif + ); private readonly SystemTrayIconWindow _IconWindow; @@ -264,7 +276,7 @@ private void OnLeftClicked() { _lastLaunchDate = DateTime.Now; - _ = Launcher.LaunchUriAsync(new Uri("files-uwp:")); + _ = Launcher.LaunchUriAsync(new Uri("files-dev:")); } else MainWindow.Instance.Activate(); diff --git a/src/Files.App/ViewModels/Settings/GeneralViewModel.cs b/src/Files.App/ViewModels/Settings/GeneralViewModel.cs index 6713d39dd31e..821a54cb6fc0 100644 --- a/src/Files.App/ViewModels/Settings/GeneralViewModel.cs +++ b/src/Files.App/ViewModels/Settings/GeneralViewModel.cs @@ -126,7 +126,7 @@ private async void DoRestartAsync() AppLifecycleHelper.SaveSessionTabs(); // Launches a new instance of Files - await Launcher.LaunchUriAsync(new Uri("files-uwp:")); + await Launcher.LaunchUriAsync(new Uri("files-dev:")); // Closes the current instance Process.GetCurrentProcess().Kill();