Skip to content

Commit fbb78ae

Browse files
committed
Init
1 parent 99b8408 commit fbb78ae

File tree

12 files changed

+90
-28
lines changed

12 files changed

+90
-28
lines changed

.github/scripts/Configure-AppxManifest.ps1

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ param(
1111
[string]$SecretGitHubOAuthClientId = ""
1212
)
1313

14+
# Load Package.appxmanifest
1415
[xml]$xmlDoc = Get-Content $PackageManifestPath
16+
17+
# Add namespaces
18+
$nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable)
19+
$nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
20+
$nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities")
21+
$nsmgr.AddNamespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10")
22+
$nsmgr.AddNamespace("uap5", "http://schemas.microsoft.com/appx/manifest/uap/windows10/5")
23+
24+
# Update the publisher
1525
$xmlDoc.Package.Identity.Publisher = $Publisher
1626

1727
if ($Branch -eq "Preview")
@@ -21,13 +31,27 @@ if ($Branch -eq "Preview")
2131
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
2232
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
2333
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files - Preview"
34+
35+
# Update app protocol and execution alias
36+
$ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']", $nsmgr)
37+
$ap.Attributes["Name"]="files-pre";
38+
$aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr)
39+
$aea.Attributes["Alias"]="files-pre.exe";
40+
41+
# Save modified Package.appxmanifest
2442
$xmlDoc.Save($PackageManifestPath)
2543

2644
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
2745
{ `
2846
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
2947
Set-Content $_ -NoNewline `
3048
}
49+
50+
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
51+
{ `
52+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-pre" }) | `
53+
Set-Content $_ -NoNewline `
54+
}
3155
}
3256
elseif ($Branch -eq "Stable")
3357
{
@@ -36,13 +60,27 @@ elseif ($Branch -eq "Stable")
3660
$xmlDoc.Package.Properties.DisplayName="Files"
3761
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
3862
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files"
63+
64+
# Update app protocol and execution alias
65+
$ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']", $nsmgr)
66+
$ap.Attributes["Name"]="files";
67+
$aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr)
68+
$aea.Attributes["Alias"]="files.exe";
69+
70+
# Save modified Package.appxmanifest
3971
$xmlDoc.Save($PackageManifestPath)
4072

4173
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
4274
{ `
4375
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
4476
Set-Content $_ -NoNewline `
4577
}
78+
79+
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
80+
{ `
81+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files" }) | `
82+
Set-Content $_ -NoNewline `
83+
}
4684
}
4785
elseif ($Branch -eq "Store")
4886
{
@@ -53,18 +91,29 @@ elseif ($Branch -eq "Store")
5391
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files"
5492

5593
# Remove an capability that is used for the sideload
56-
$nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable)
57-
$nsmgr.AddNamespace("pkg", "http://schemas.microsoft.com/appx/manifest/foundation/windows10")
58-
$nsmgr.AddNamespace("rescap", "http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities")
5994
$pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr)
6095
$xmlDoc.Package.Capabilities.RemoveChild($pm)
96+
97+
# Update app protocol and execution alias
98+
$ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']", $nsmgr)
99+
$ap.Attributes["Name"]="files";
100+
$aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr)
101+
$aea.Attributes["Alias"]="files.exe";
102+
103+
# Save modified Package.appxmanifest
61104
$xmlDoc.Save($PackageManifestPath)
62105

63106
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
64107
{ `
65108
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
66109
Set-Content $_ -NoNewline `
67110
}
111+
112+
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
113+
{ `
114+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files" }) | `
115+
Set-Content $_ -NoNewline `
116+
}
68117
}
69118

70119
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `

src/Files.App (Package)/Package.appxmanifest

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,14 @@
119119
</uap3:Extension>
120120

121121
<uap:Extension Category="windows.protocol">
122-
<uap:Protocol ReturnResults="none" Name="files-uwp" />
122+
<!-- This value changes based on the build branch (files, files-pre, files-dev). -->
123+
<uap:Protocol ReturnResults="none" Name="files-dev" />
123124
</uap:Extension>
124125

125126
<uap5:Extension Category="windows.appExecutionAlias">
126127
<uap5:AppExecutionAlias>
127-
<uap5:ExecutionAlias Alias="files.exe" />
128+
<!-- This value changes based on the build branch (files, files-pre, files-dev). -->
129+
<uap5:ExecutionAlias Alias="files-dev.exe" />
128130
</uap5:AppExecutionAlias>
129131
</uap5:Extension>
130132

src/Files.App.Launcher/FilesLauncher.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
6565
LocalFree(szArglist);
6666

6767
WCHAR szBuf[MAX_PATH];
68-
ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1);
68+
ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1);
6969
std::wcout << szBuf << std::endl;
7070
if (_waccess(szBuf, 0) == -1)
7171
{
@@ -172,7 +172,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
172172
swprintf(args, _countof(args) - 1, L"\"%s\" -select \"%s\"", szBuf, item.c_str());
173173
}
174174

175-
std::wstring uriWithArgs = L"files-uwp:?cmd=" + str2wstr(wstring_to_utf8_hex(args));
175+
std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args));
176176

177177
std::wcout << L"Invoking: " << args << L" = " << uriWithArgs << std::endl;
178178

@@ -187,7 +187,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
187187
{
188188
std::wcout << L"Protocol error: " << GetLastError() << std::endl;
189189

190-
//ShExecInfo.lpFile = L"files.exe";
190+
//ShExecInfo.lpFile = L"files-dev.exe";
191191
//ShExecInfo.lpParameters = args;
192192
//if (!ShellExecuteEx(&ShExecInfo))
193193
//{
@@ -202,13 +202,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
202202
SHELLEXECUTEINFO ShExecInfo = { 0 };
203203
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
204204
ShExecInfo.fMask = SEE_MASK_NOASYNC | SEE_MASK_FLAG_NO_UI;
205-
ShExecInfo.lpFile = L"files-uwp:";
205+
ShExecInfo.lpFile = L"files-dev:";
206206
ShExecInfo.nShow = SW_SHOW;
207207

208208
if (!ShellExecuteEx(&ShExecInfo))
209209
{
210210
std::wcout << L"Protocol error: " << GetLastError() << std::endl;
211-
//ShExecInfo.lpFile = L"files.exe";
211+
//ShExecInfo.lpFile = L"files-dev.exe";
212212
//if (!ShellExecuteEx(&ShExecInfo))
213213
//{
214214
//std::wcout << L"Command line error: " << GetLastError() << std::endl;

src/Files.App.OpenDialog/FilesOpenDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner)
162162
PWSTR pszPath = NULL;
163163
WCHAR szBuf[MAX_PATH];
164164
TCHAR args[1024] = { 0 };
165-
ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1);
165+
ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1);
166166

167167
HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG"));
168168

@@ -177,7 +177,7 @@ STDAPICALL CFilesOpenDialog::Show(HWND hwndOwner)
177177
swprintf(args, _countof(args) - 1, L"\"%s\" -outputpath \"%s\"", szBuf, _outputPath.c_str());
178178
}
179179

180-
std::wstring uriWithArgs = L"files-uwp:?cmd=" + str2wstr(wstring_to_utf8_hex(args));
180+
std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args));
181181
ShExecInfo.lpFile = uriWithArgs.c_str();
182182
ShExecInfo.nShow = SW_SHOW;
183183
ShellExecuteEx(&ShExecInfo);

src/Files.App.SaveDialog/FilesSaveDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner)
438438
PWSTR pszPath = NULL;
439439
WCHAR szBuf[MAX_PATH];
440440
TCHAR args[1024] = { 0 };
441-
ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files.exe", szBuf, MAX_PATH - 1);
441+
ExpandEnvironmentStringsW(L"%LOCALAPPDATA%\\Microsoft\\WindowsApps\\files-dev.exe", szBuf, MAX_PATH - 1);
442442

443443
HANDLE closeEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("FILEDIALOG"));
444444

@@ -460,7 +460,7 @@ HRESULT __stdcall CFilesSaveDialog::Show(HWND hwndOwner)
460460
swprintf(args, _countof(args) - 1, L"\"%s\" -outputpath \"%s\"", szBuf, _outputPath.c_str());
461461
}
462462

463-
std::wstring uriWithArgs = L"files-uwp:?cmd=" + str2wstr(wstring_to_utf8_hex(args));
463+
std::wstring uriWithArgs = L"files-dev:?cmd=" + str2wstr(wstring_to_utf8_hex(args));
464464
ShExecInfo.lpFile = uriWithArgs.c_str();
465465
ShExecInfo.nShow = SW_SHOW;
466466
ShellExecuteEx(&ShExecInfo);

src/Files.App/Actions/Navigation/OpenInNewWindow/BaseOpenInNewWindowAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public virtual async Task ExecuteAsync(object? parameter = null)
5050
foreach (ListedItem listedItem in items)
5151
{
5252
var selectedItemPath = (listedItem as ShortcutItem)?.TargetPath ?? listedItem.ItemPath;
53-
var folderUri = new Uri($"files-uwp:?folder={@selectedItemPath}");
53+
var folderUri = new Uri($"files-dev:?folder={@selectedItemPath}");
5454

5555
await Launcher.LaunchUriAsync(folderUri);
5656
}

src/Files.App/Helpers/Application/AppLifecycleHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public static void HandleAppUnhandledException(Exception? ex, bool showToastNoti
340340
// Try to re-launch and start over
341341
MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
342342
{
343-
await Launcher.LaunchUriAsync(new Uri("files-uwp:"));
343+
await Launcher.LaunchUriAsync(new Uri("files-dev:"));
344344
})
345345
.Wait(100);
346346
}

src/Files.App/Helpers/Navigation/NavigationHelpers.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,14 @@ public static Task<bool> OpenPathInNewWindowAsync(string? path)
286286
if (string.IsNullOrWhiteSpace(path))
287287
return Task.FromResult(false);
288288

289-
var folderUri = new Uri($"files-uwp:?folder={Uri.EscapeDataString(path)}");
289+
var folderUri = new Uri($"files-dev:?folder={Uri.EscapeDataString(path)}");
290290

291291
return Launcher.LaunchUriAsync(folderUri).AsTask();
292292
}
293293

294294
public static Task<bool> OpenTabInNewWindowAsync(string tabArgs)
295295
{
296-
var folderUri = new Uri($"files-uwp:?tab={Uri.EscapeDataString(tabArgs)}");
296+
var folderUri = new Uri($"files-dev:?tab={Uri.EscapeDataString(tabArgs)}");
297297
return Launcher.LaunchUriAsync(folderUri).AsTask();
298298
}
299299

@@ -307,8 +307,7 @@ public static void OpenInSecondaryPane(IShellPage associatedInstance, ListedItem
307307

308308
public static Task LaunchNewWindowAsync()
309309
{
310-
var filesUWPUri = new Uri("files-uwp:?window=");
311-
return Launcher.LaunchUriAsync(filesUWPUri).AsTask();
310+
return Launcher.LaunchUriAsync(new Uri("files-dev:?window=")).AsTask();
312311
}
313312

314313
public static async Task OpenSelectedItemsAsync(IShellPage associatedInstance, bool openViaApplicationPicker = false)

src/Files.App/MainWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
5252
{
5353
case ILaunchActivatedEventArgs launchArgs:
5454
if (launchArgs.Arguments is not null &&
55-
(CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files.exe", StringComparison.OrdinalIgnoreCase)
56-
|| CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files", StringComparison.OrdinalIgnoreCase)))
55+
(CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files-dev.exe", StringComparison.OrdinalIgnoreCase)
56+
|| CommandLineParser.SplitArguments(launchArgs.Arguments, true)[0].EndsWith($"files-dev", StringComparison.OrdinalIgnoreCase)))
5757
{
5858
// WINUI3: When launching from commandline the argument is not ICommandLineActivatedEventArgs (#10370)
5959
var ppm = CommandLineParser.ParseUntrustedCommands(launchArgs.Arguments);
@@ -82,7 +82,7 @@ public async Task InitializeApplicationAsync(object activatedEventArgs)
8282
break;
8383

8484
case IProtocolActivatedEventArgs eventArgs:
85-
if (eventArgs.Uri.AbsoluteUri == "files-uwp:")
85+
if (eventArgs.Uri.AbsoluteUri == "files-dev:")
8686
{
8787
rootFrame.Navigate(typeof(MainPage), null, new SuppressNavigationTransitionInfo());
8888

src/Files.App/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ static bool ProcessPathPredicate(Process p)
220220
var cmdLaunchArgs = activatedArgs.Data is ILaunchActivatedEventArgs launchArgs &&
221221
launchArgs.Arguments is not null &&
222222
CommandLineParser.SplitArguments(launchArgs.Arguments, true).FirstOrDefault() is string arg0 &&
223-
(arg0.EndsWith($"files.exe", StringComparison.OrdinalIgnoreCase) ||
224-
arg0.EndsWith($"files", StringComparison.OrdinalIgnoreCase)) ? launchArgs.Arguments : null;
223+
(arg0.EndsWith($"files-dev.exe", StringComparison.OrdinalIgnoreCase) ||
224+
arg0.EndsWith($"files-dev", StringComparison.OrdinalIgnoreCase)) ? launchArgs.Arguments : null;
225225
var cmdProtocolArgs = activatedArgs.Data is IProtocolActivatedEventArgs protocolArgs &&
226226
protocolArgs.Uri.Query.TrimStart('?').Split('=') is string[] parsedArgs &&
227227
parsedArgs.Length == 2 && parsedArgs[0] == "cmd" ? Uri.UnescapeDataString(parsedArgs[1]) : null;

0 commit comments

Comments
 (0)