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 `
diff --git a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
index 4b60d6a7c27a..2c14ea1d8a4a 100644
--- a/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
+++ b/src/Files.App/Helpers/Application/AppLifecycleHelper.cs
@@ -29,16 +29,10 @@ public static class AppLifecycleHelper
///
/// Gets the value that provides application environment or branch name.
///
- public static AppEnvironment AppEnvironment
- {
- get
- {
- if (Enum.TryParse("cd_app_env_placeholder", true, out AppEnvironment appEnvironment))
- return appEnvironment;
- else
- return AppEnvironment.Dev;
- }
- }
+ public static AppEnvironment AppEnvironment =>
+ Enum.TryParse("cd_app_env_placeholder", true, out AppEnvironment appEnvironment))
+ ? appEnvironment;
+ : AppEnvironment.Dev;
///
/// Gets application package version.
@@ -53,8 +47,7 @@ public static AppEnvironment AppEnvironment
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
});
@@ -138,7 +131,7 @@ public static void ConfigureSentry()
///
public static IHost ConfigureHost()
{
- return Host.CreateDefaultBuilder()
+ var builder = Host.CreateDefaultBuilder()
.UseEnvironment(AppLifecycleHelper.AppEnvironment.ToString())
.ConfigureLogging(builder => builder
.ClearProviders()
@@ -187,13 +180,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()
@@ -228,7 +214,17 @@ public static IHost ConfigureHost()
.AddSingleton()
.AddSingleton()
.AddSingleton()
- ).Build();
+ );
+
+ // Conditional DI
+ if (AppEnvironment is AppEnvironment.SideloadPreview or AppEnvironment.SideloadStable)
+ builder.ConfigureServices(s => s.AddSingleton());
+ else if (AppEnvironment is AppEnvironment.StorePreview or AppEnvironment.StoreStable)
+ builder.ConfigureServices(s => s.AddSingleton());
+ else
+ builder.ConfigureServices(s => s.AddSingleton());
+
+ return builder.Build();
}
///