Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 23 additions & 41 deletions .github/scripts/Configure-AppxManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "",
Expand All @@ -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 `
}
}
Expand All @@ -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")
{
Expand All @@ -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 `
Expand Down
26 changes: 14 additions & 12 deletions src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#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

Check failure on line 36 in src/Files.App/Helpers/Application/AppLifecycleHelper.cs

View workflow job for this annotation

GitHub Actions / build (Release, x64)

'AppEnvironment' does not contain a definition for 'cd_app_env_placeholder' and no accessible extension method 'cd_app_env_placeholder' accepting a first argument of type 'AppEnvironment' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 36 in src/Files.App/Helpers/Application/AppLifecycleHelper.cs

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

'AppEnvironment' does not contain a definition for 'cd_app_env_placeholder' and no accessible extension method 'cd_app_env_placeholder' accepting a first argument of type 'AppEnvironment' could be found (are you missing a using directive or an assembly reference?)
#endif

/// <summary>
Expand All @@ -49,8 +49,7 @@
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
});

Expand Down Expand Up @@ -134,7 +133,7 @@
/// </summary>
public static IHost ConfigureHost()
{
return Host.CreateDefaultBuilder()
var builder = Host.CreateDefaultBuilder()
.UseEnvironment(AppLifecycleHelper.AppEnvironment.ToString())
.ConfigureLogging(builder => builder
.ClearProviders()
Expand Down Expand Up @@ -183,13 +182,6 @@
.AddSingleton<IStorageService, NativeStorageLegacyService>()
.AddSingleton<IFtpStorageService, FtpStorageService>()
.AddSingleton<IAddItemService, AddItemService>()
#if SIDELOAD_STABLE || SIDELOAD_PREVIEW
.AddSingleton<IUpdateService, SideloadUpdateService>()
#elif STORE_STABLE || STORE_PREVIEW
.AddSingleton<IUpdateService, StoreUpdateService>()
#else
.AddSingleton<IUpdateService, DummyUpdateService>()
#endif
.AddSingleton<IPreviewPopupService, PreviewPopupService>()
.AddSingleton<IDateTimeFormatterFactory, DateTimeFormatterFactory>()
.AddSingleton<IDateTimeFormatter, UserDateTimeFormatter>()
Expand Down Expand Up @@ -224,7 +216,17 @@
.AddSingleton<FileTagsManager>()
.AddSingleton<LibraryManager>()
.AddSingleton<AppModel>()
).Build();
);

// Conditional DI
if (AppEnvironment is AppEnvironment.SideloadPreview or AppEnvironment.SideloadStable)
builder.ConfigureServices(s => s.AddSingleton<IUpdateService, SideloadUpdateService>());
else if (AppEnvironment is AppEnvironment.StorePreview or AppEnvironment.StoreStable)
builder.ConfigureServices(s => s.AddSingleton<IUpdateService, StoreUpdateService>());
else
builder.ConfigureServices(s => s.AddSingleton<IUpdateService, DummyUpdateService>());

return builder.Build();
}

/// <summary>
Expand Down
Loading