Skip to content

Commit fa41230

Browse files
committed
Try
1 parent fdea058 commit fa41230

File tree

9 files changed

+374
-176
lines changed

9 files changed

+374
-176
lines changed
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Copyright (c) Files Community
2+
# Licensed under the MIT License.
3+
4+
param(
5+
[string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
6+
[string]$PackageManifestPath = "",
7+
[string]$Publisher = "",
8+
[string]$WorkingDir = "",
9+
[string]$SecretBingMapsKey = "",
10+
[string]$SecretSentry = "",
11+
[string]$SecretGitHubOAuthClientId = ""
12+
)
13+
14+
# Load Package.appxmanifest
15+
[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
28+
$xmlDoc.Package.Identity.Publisher = $Publisher
29+
30+
if ($Branch -eq "SideloadPreview")
31+
{
32+
# Set identities
33+
$xmlDoc.Package.Identity.Name="FilesPreview"
34+
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
35+
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
36+
$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+
76+
$xmlDoc.Save($PackageManifestPath)
77+
78+
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
79+
{ `
80+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
81+
Set-Content $_ -NoNewline `
82+
}
83+
84+
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
85+
{ `
86+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | `
87+
Set-Content $_ -NoNewline `
88+
}
89+
}
90+
elseif ($Branch -eq "SideloadStable")
91+
{
92+
# Set identities
93+
$xmlDoc.Package.Identity.Name="Files"
94+
$xmlDoc.Package.Properties.DisplayName="Files"
95+
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
96+
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files"
97+
98+
# Update app protocol and execution alias
99+
$ap.SetAttribute("Name", "files-stable");
100+
$ea.SetAttribute("Alias", "files-stable.exe");
101+
102+
# Save modified Package.appxmanifest
103+
$xmlDoc.Save($PackageManifestPath)
104+
105+
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
106+
{ `
107+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
108+
Set-Content $_ -NoNewline `
109+
}
110+
111+
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
112+
{ `
113+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
114+
Set-Content $_ -NoNewline `
115+
}
116+
}
117+
elseif ($Branch -eq "StoreStable")
118+
{
119+
# Set identities
120+
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP"
121+
$xmlDoc.Package.Properties.DisplayName="Files App"
122+
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
123+
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files"
124+
125+
# Remove capability that is only used for the sideload package
126+
$pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr)
127+
$xmlDoc.Package.Capabilities.RemoveChild($pm)
128+
129+
# Update app protocol and execution alias
130+
$ap.SetAttribute("Name", "files-stable");
131+
$ea.SetAttribute("Alias", "files-stable.exe");
132+
133+
# Save modified Package.appxmanifest
134+
$xmlDoc.Save($PackageManifestPath)
135+
136+
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
137+
{ `
138+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
139+
Set-Content $_ -NoNewline `
140+
}
141+
142+
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
143+
{ `
144+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
145+
Set-Content $_ -NoNewline `
146+
}
147+
}
148+
149+
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
150+
{ `
151+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | `
152+
Set-Content $_ -NoNewline `
153+
}
154+
155+
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
156+
{ `
157+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | `
158+
Set-Content $_ -NoNewline `
159+
}
160+
161+
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
162+
{
163+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | `
164+
Set-Content $_ -NoNewline `
165+
}
166+
167+
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
168+
{ `
169+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | `
170+
Set-Content $_ -NoNewline `
171+
}

.github/scripts/Configure-AppxManifest.ps1

Lines changed: 28 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44
param(
55
[string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
66
[string]$PackageManifestPath = "",
7-
[string]$Publisher = "",
87
[string]$WorkingDir = "",
9-
[string]$SecretBingMapsKey = "",
10-
[string]$SecretSentry = "",
11-
[string]$SecretGitHubOAuthClientId = ""
8+
[string]$IsBuildingInVisualStudio = "false"
129
)
1310

1411
# Load Package.appxmanifest
@@ -24,8 +21,10 @@ $ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pk
2421
$aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr)
2522
$ea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias/uap5:ExecutionAlias", $nsmgr)
2623

24+
$IsBuildingInVisualStudio = [System.Convert]::ToBoolean($IsBuildingInVisualStudio)
25+
2726
# Update the publisher
28-
$xmlDoc.Package.Identity.Publisher = $Publisher
27+
#$xmlDoc.Package.Identity.Publisher = $Publisher
2928

3029
if ($Branch -eq "SideloadPreview")
3130
{
@@ -41,18 +40,6 @@ if ($Branch -eq "SideloadPreview")
4140

4241
# Save modified Package.appxmanifest
4342
$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-
}
5643
}
5744
elseif ($Branch -eq "StorePreview")
5845
{
@@ -77,14 +64,18 @@ elseif ($Branch -eq "StorePreview")
7764

7865
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
7966
{ `
80-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
81-
Set-Content $_ -NoNewline `
67+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" })
68+
if (!$IsBuildingInVisualStudio) {
69+
Set-Content $_ -NoNewline
70+
}
8271
}
8372

8473
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
8574
{ `
86-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | `
87-
Set-Content $_ -NoNewline `
75+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" })
76+
if (!$IsBuildingInVisualStudio) {
77+
Set-Content $_ -NoNewline
78+
}
8879
}
8980
}
9081
elseif ($Branch -eq "SideloadStable")
@@ -104,14 +95,18 @@ elseif ($Branch -eq "SideloadStable")
10495

10596
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
10697
{ `
107-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
108-
Set-Content $_ -NoNewline `
98+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" })
99+
if (!$IsBuildingInVisualStudio) {
100+
Set-Content $_ -NoNewline
101+
}
109102
}
110103

111104
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
112105
{ `
113-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
114-
Set-Content $_ -NoNewline `
106+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" })
107+
if (!$IsBuildingInVisualStudio) {
108+
Set-Content $_ -NoNewline
109+
}
115110
}
116111
}
117112
elseif ($Branch -eq "StoreStable")
@@ -135,37 +130,17 @@ elseif ($Branch -eq "StoreStable")
135130

136131
Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
137132
{ `
138-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
139-
Set-Content $_ -NoNewline `
133+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" })
134+
if (!$IsBuildingInVisualStudio) {
135+
Set-Content $_ -NoNewline
136+
}
140137
}
141138

142139
Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
143140
{ `
144-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
145-
Set-Content $_ -NoNewline `
141+
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" })
142+
if (!$IsBuildingInVisualStudio) {
143+
Set-Content $_ -NoNewline
144+
}
146145
}
147146
}
148-
149-
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
150-
{ `
151-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | `
152-
Set-Content $_ -NoNewline `
153-
}
154-
155-
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
156-
{ `
157-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | `
158-
Set-Content $_ -NoNewline `
159-
}
160-
161-
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
162-
{
163-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | `
164-
Set-Content $_ -NoNewline `
165-
}
166-
167-
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
168-
{ `
169-
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | `
170-
Set-Content $_ -NoNewline `
171-
}

Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
<RepoDir>$(RootDir)\.github</RepoDir>
1010

1111
<AppXManifestProvider>$(BuildDir)\PackageManifest.props</AppXManifestProvider>
12+
<AppXManifestGenerator>$(BuildDir)\MakeAppXManifest.targets</AppXManifestGenerator>
1213
<AppXPackageProjectPath>$(SourceDir)\Files.App (Package)</AppXPackageProjectPath>
14+
<AppXManifestFile>$(BuildDir)\Package.appxmanifest</AppXManifestFile>
1315
</PropertyGroup>
1416

1517
<!-- Target framework -->

0 commit comments

Comments
 (0)