From a61d5b4efbddd9e3bd531d5b3d7ba9e90dc810e8 Mon Sep 17 00:00:00 2001
From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com>
Date: Fri, 6 Dec 2024 11:17:47 +0900
Subject: [PATCH 1/4] Update AppLifecycleHelper.cs
---
.../Helpers/Application/AppLifecycleHelper.cs | 26 ++++++++++---------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
index 17c49bd2e7bf..601e37d1313d 100644
--- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
+++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
@@ -33,7 +33,7 @@ public static class AppLifecycleHelper
#if DEBUG
AppEnvironment.Dev;
#else
- AppEnvironment.cd_app_env_placeholder;
+ AppEnvironment.cd_app_env_placeholder; // This is replaced to an appropriate enum value by a CD pipeline
#endif
///
@@ -49,8 +49,7 @@ public static class AppLifecycleHelper
SystemIO.Path.Combine(Package.Current.InstalledLocation.Path, AppEnvironment switch
{
AppEnvironment.Dev => Constants.AssetPaths.DevLogo,
- AppEnvironment.SideloadPreview => Constants.AssetPaths.PreviewLogo,
- AppEnvironment.StorePreview => Constants.AssetPaths.PreviewLogo,
+ AppEnvironment.SideloadPreview or AppEnvironment.StorePreview => Constants.AssetPaths.PreviewLogo,
_ => Constants.AssetPaths.StableLogo
});
@@ -134,7 +133,7 @@ public static void ConfigureSentry()
///
public static IHost ConfigureHost()
{
- return Host.CreateDefaultBuilder()
+ var builder = Host.CreateDefaultBuilder()
.UseEnvironment(AppLifecycleHelper.AppEnvironment.ToString())
.ConfigureLogging(builder => builder
.ClearProviders()
@@ -183,13 +182,6 @@ public static IHost ConfigureHost()
.AddSingleton()
.AddSingleton()
.AddSingleton()
-#if SIDELOAD_STABLE || SIDELOAD_PREVIEW
- .AddSingleton()
-#elif STORE_STABLE || STORE_PREVIEW
- .AddSingleton()
-#else
- .AddSingleton()
-#endif
.AddSingleton()
.AddSingleton()
.AddSingleton()
@@ -224,7 +216,17 @@ public static IHost ConfigureHost()
.AddSingleton()
.AddSingleton()
.AddSingleton()
- ).Build();
+ );
+
+ // Conditional DI
+ if (AppEnvironment is AppEnvironment.SideloadPreview or AppEnvironment.SideloadStable)
+ builder.AddSingleton();
+ else if (AppEnvironment is AppEnvironment.StorePreview or AppEnvironment.StoreStable)
+ builder.AddSingleton();
+ else
+ builder.AddSingleton();
+
+ return builder.Build();
}
///
From 268e6407b809adacfbe6ad96f53d83f929a0d71c Mon Sep 17 00:00:00 2001
From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com>
Date: Fri, 6 Dec 2024 11:25:51 +0900
Subject: [PATCH 2/4] Update Configure-AppxManifest.ps1
---
.github/scripts/Configure-AppxManifest.ps1 | 64 ++++++++--------------
1 file changed, 23 insertions(+), 41 deletions(-)
diff --git a/.github/scripts/Configure-AppxManifest.ps1 b/.github/scripts/Configure-AppxManifest.ps1
index a46b77c9227b..db8838e1abc8 100644
--- a/.github/scripts/Configure-AppxManifest.ps1
+++ b/.github/scripts/Configure-AppxManifest.ps1
@@ -2,7 +2,7 @@
# Licensed under the MIT License. See the LICENSE.
param(
- [string]$Branch = "",
+ [string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
[string]$PackageManifestPath = "",
[string]$Publisher = "",
[string]$WorkingDir = "",
@@ -28,10 +28,26 @@ if ($Branch -eq "SideloadPreview")
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
Set-Content $_ -NoNewline `
}
+}
+elseif ($Branch -eq "StorePreview")
+{
+ # Set identities
+ $xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview"
+ $xmlDoc.Package.Properties.DisplayName="Files - Preview"
+ $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
+ $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="49306atecsolution.FilesPreview"
- Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
+ # 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)
+ $xmlDoc.Save($PackageManifestPath)
+
+ Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
{ `
- (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", "SideloadPreview" }) | `
+ (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
Set-Content $_ -NoNewline `
}
}
@@ -49,12 +65,6 @@ elseif ($Branch -eq "SideloadStable")
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
Set-Content $_ -NoNewline `
}
-
- Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
- { `
- (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", "SideloadStable" }) | `
- Set-Content $_ -NoNewline `
- }
}
elseif ($Branch -eq "StoreStable")
{
@@ -77,40 +87,12 @@ elseif ($Branch -eq "StoreStable")
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
Set-Content $_ -NoNewline `
}
-
- Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
- { `
- (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", "StoreStable" }) | `
- Set-Content $_ -NoNewline `
- }
}
-elseif ($Branch -eq "StorePreview")
-{
- # Set identities
- $xmlDoc.Package.Identity.Name="49306atecsolution.FilesPreview"
- $xmlDoc.Package.Properties.DisplayName="Files - Preview"
- $xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
- $xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="49306atecsolution.FilesPreview"
-
- # 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)
- $xmlDoc.Save($PackageManifestPath)
-
- Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
- { `
- (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" }) | `
- Set-Content $_ -NoNewline `
- }
- Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
- { `
- (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", "StorePreview" }) | `
- Set-Content $_ -NoNewline `
- }
+Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
+{ `
+ (Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "cd_app_env_placeholder", $Branch }) | `
+ Set-Content $_ -NoNewline `
}
Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
From fae90911ade0d2a7c479d2af584edb2ce464efff Mon Sep 17 00:00:00 2001
From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com>
Date: Fri, 6 Dec 2024 11:43:25 +0900
Subject: [PATCH 3/4] Update AppLifecycleHelper.cs
---
src/Files.App/Helpers/Application/AppLifecycleHelper.cs | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
index 601e37d1313d..27a9c299461b 100644
--- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
+++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
@@ -220,11 +220,11 @@ public static IHost ConfigureHost()
// Conditional DI
if (AppEnvironment is AppEnvironment.SideloadPreview or AppEnvironment.SideloadStable)
- builder.AddSingleton();
+ builder.ConfigureServices(s => s.AddSingleton());
else if (AppEnvironment is AppEnvironment.StorePreview or AppEnvironment.StoreStable)
- builder.AddSingleton();
+ builder.ConfigureServices(s => s.AddSingleton());
else
- builder.AddSingleton();
+ builder.ConfigureServices(s => s.AddSingleton());
return builder.Build();
}
From 1719008dd809f9badd6ecb23b0eeb10ded960478 Mon Sep 17 00:00:00 2001
From: 0x5BFA <62196528+0x5bfa@users.noreply.github.com>
Date: Fri, 6 Dec 2024 12:06:41 +0900
Subject: [PATCH 4/4] Update AppLifecycleHelper.cs
---
src/Files.App/Helpers/Application/AppLifecycleHelper.cs | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
index c68e3117a85d..2c14ea1d8a4a 100644
--- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
+++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
@@ -33,8 +33,6 @@ public static class AppLifecycleHelper
Enum.TryParse("cd_app_env_placeholder", true, out AppEnvironment appEnvironment))
? appEnvironment;
: AppEnvironment.Dev;
- }
- }
///
/// Gets application package version.