Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
38 changes: 17 additions & 21 deletions src/Files.App/Helpers/Application/AppLifecycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,10 @@
/// <summary>
/// Gets the value that provides application environment or branch name.
/// </summary>
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))

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

; expected

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

Invalid token ')' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

; expected

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

Invalid token ')' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

; expected

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

Invalid token ')' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

; expected

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

Invalid token ')' in class, record, struct, or interface member declaration
? appEnvironment;

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

Invalid token ';' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

Invalid token ';' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

Invalid token ';' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

Invalid token ';' in class, record, struct, or interface member declaration
: AppEnvironment.Dev;

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

View workflow job for this annotation

GitHub Actions / build (Debug, x64)

Invalid token ';' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Debug, arm64)

Invalid token ';' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Release, x64)

Invalid token ';' in class, record, struct, or interface member declaration

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

View workflow job for this annotation

GitHub Actions / build (Release, arm64)

Invalid token ';' in class, record, struct, or interface member declaration

/// <summary>
/// Gets application package version.
Expand All @@ -53,8 +47,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 @@ -138,7 +131,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 @@ -187,13 +180,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 @@ -228,7 +214,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