22# Licensed under the MIT License. See the LICENSE.
33
44param (
5- [string ]$Branch = " " ,
5+ [string ]$Branch = " " , # This has to correspond with one of the AppEnvironment enum values
66 [string ]$PackageManifestPath = " " ,
77 [string ]$Publisher = " " ,
88 [string ]$WorkingDir = " " ,
@@ -11,16 +11,68 @@ 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+ $ap = $xmlDoc.SelectSingleNode (" /pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']/uap:Protocol" , $nsmgr )
24+ $aea = $xmlDoc.SelectSingleNode (" /pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias" , $nsmgr )
25+ $ea = $xmlDoc.SelectSingleNode (" /pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias/uap5:ExecutionAlias" , $nsmgr )
26+
27+ # Update the publisher
1528$xmlDoc.Package.Identity.Publisher = $Publisher
1629
17- if ($Branch -eq " Preview " )
30+ if ($Branch -eq " SideloadPreview " )
1831{
1932 # Set identities
2033 $xmlDoc.Package.Identity.Name = " FilesPreview"
2134 $xmlDoc.Package.Properties.DisplayName = " Files - Preview"
2235 $xmlDoc.Package.Applications.Application.VisualElements.DisplayName = " Files - Preview"
2336 $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName = " Files - Preview"
37+
38+ # Update app protocol and execution alias
39+ $ap.SetAttribute (" Name" , " files-preview" );
40+ $ea.SetAttribute (" Alias" , " files-preview.exe" );
41+
42+ # Save modified Package.appxmanifest
43+ $xmlDoc.Save ($PackageManifestPath )
44+
45+ Get-ChildItem $WorkingDir - Include * .csproj, * .appxmanifest, * .wapproj, * .xaml - recurse | ForEach-Object - Process `
46+ { `
47+ (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " Assets\\AppTiles\\Dev" , " Assets\AppTiles\Preview" }) | `
48+ Set-Content $_ - NoNewline `
49+ }
50+
51+ Get-ChildItem $WorkingDir - Include * .cs, * .cpp - recurse | ForEach-Object - Process `
52+ { `
53+ (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " files-dev" , " files-preview" }) | `
54+ Set-Content $_ - NoNewline `
55+ }
56+ }
57+ elseif ($Branch -eq " StorePreview" )
58+ {
59+ # Set identities
60+ $xmlDoc.Package.Identity.Name = " 49306atecsolution.FilesPreview"
61+ $xmlDoc.Package.Properties.DisplayName = " Files - Preview"
62+ $xmlDoc.Package.Applications.Application.VisualElements.DisplayName = " Files - Preview"
63+ $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName = " 49306atecsolution.FilesPreview"
64+
65+ # Remove capability that is only used for the sideload package
66+ $nsmgr = New-Object System.Xml.XmlNamespaceManager($xmlDoc.NameTable )
67+ $nsmgr.AddNamespace (" pkg" , " http://schemas.microsoft.com/appx/manifest/foundation/windows10" )
68+ $nsmgr.AddNamespace (" rescap" , " http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" )
69+ $pm = $xmlDoc.SelectSingleNode (" /pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']" , $nsmgr )
70+ $xmlDoc.Package.Capabilities.RemoveChild ($pm )
71+
72+ # Update app protocol and execution alias
73+ $ap.SetAttribute (" Name" , " files-preview" );
74+ $ea.SetAttribute (" Alias" , " files-preview.exe" );
75+
2476 $xmlDoc.Save ($PackageManifestPath )
2577
2678 Get-ChildItem $WorkingDir - Include * .csproj, * .appxmanifest, * .wapproj, * .xaml - recurse | ForEach-Object - Process `
@@ -29,42 +81,69 @@ if ($Branch -eq "Preview")
2981 Set-Content $_ - NoNewline `
3082 }
3183}
32- elseif ($Branch -eq " Stable " )
84+ elseif ($Branch -eq " SideloadStable " )
3385{
3486 # Set identities
3587 $xmlDoc.Package.Identity.Name = " Files"
3688 $xmlDoc.Package.Properties.DisplayName = " Files"
3789 $xmlDoc.Package.Applications.Application.VisualElements.DisplayName = " Files"
3890 $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName = " Files"
91+
92+ # Update app protocol and execution alias
93+ $ap.SetAttribute (" Name" , " files-stable" );
94+ $ea.SetAttribute (" Alias" , " files-stable.exe" );
95+
96+ # Save modified Package.appxmanifest
3997 $xmlDoc.Save ($PackageManifestPath )
4098
4199 Get-ChildItem $WorkingDir - Include * .csproj, * .appxmanifest, * .wapproj, * .xaml - recurse | ForEach-Object - Process `
42100 { `
43101 (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " Assets\\AppTiles\\Dev" , " Assets\AppTiles\Release" }) | `
44102 Set-Content $_ - NoNewline `
45103 }
104+
105+ Get-ChildItem $WorkingDir - Include * .cs, * .cpp - recurse | ForEach-Object - Process `
106+ { `
107+ (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " files-dev" , " files-stable" }) | `
108+ Set-Content $_ - NoNewline `
109+ }
46110}
47- elseif ($Branch -eq " Store " )
111+ elseif ($Branch -eq " StoreStable " )
48112{
49113 # Set identities
50114 $xmlDoc.Package.Identity.Name = " 49306atecsolution.FilesUWP"
51115 $xmlDoc.Package.Properties.DisplayName = " Files App"
52116 $xmlDoc.Package.Applications.Application.VisualElements.DisplayName = " Files"
53117 $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName = " Files"
54118
55- # 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" )
119+ # Remove capability that is only used for the sideload package
59120 $pm = $xmlDoc.SelectSingleNode (" /pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']" , $nsmgr )
60121 $xmlDoc.Package.Capabilities.RemoveChild ($pm )
122+
123+ # Update app protocol and execution alias
124+ $ap.SetAttribute (" Name" , " files" );
125+ $aea.RemoveChild ($aea.FirstChild ); # Avoid duplication
126+
127+ # Save modified Package.appxmanifest
61128 $xmlDoc.Save ($PackageManifestPath )
62129
63130 Get-ChildItem $WorkingDir - Include * .csproj, * .appxmanifest, * .wapproj, * .xaml - recurse | ForEach-Object - Process `
64131 { `
65132 (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " Assets\\AppTiles\\Dev" , " Assets\AppTiles\Release" }) | `
66133 Set-Content $_ - NoNewline `
67134 }
135+
136+ Get-ChildItem $WorkingDir - Include * .cs, * .cpp - recurse | ForEach-Object - Process `
137+ { `
138+ (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " files-dev" , " files" }) | `
139+ Set-Content $_ - NoNewline `
140+ }
141+ }
142+
143+ Get-ChildItem $WorkingDir - Include * .cs - recurse | ForEach-Object - Process `
144+ { `
145+ (Get-Content $_ - Raw | ForEach-Object - Process { $_ -replace " cd_app_env_placeholder" , $Branch }) | `
146+ Set-Content $_ - NoNewline `
68147}
69148
70149Get-ChildItem $WorkingDir - Include * .cs - recurse | ForEach-Object - Process `
0 commit comments