Skip to content

Code Quality: Introduced a new build experience #17025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
171 changes: 171 additions & 0 deletions .github/scripts/Configure-AppServices.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Copyright (c) Files Community
# Licensed under the MIT License.

param(
[string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
[string]$PackageManifestPath = "",
[string]$Publisher = "",
[string]$WorkingDir = "",
[string]$SecretBingMapsKey = "",
[string]$SecretSentry = "",
[string]$SecretGitHubOAuthClientId = ""
)

# Load Package.appxmanifest
[xml]$xmlDoc = Get-Content $PackageManifestPath

# Add namespaces
$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")
$nsmgr.AddNamespace("uap", "http://schemas.microsoft.com/appx/manifest/uap/windows10")
$nsmgr.AddNamespace("uap5", "http://schemas.microsoft.com/appx/manifest/uap/windows10/5")
$ap = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap:Extension[@Category='windows.protocol']/uap:Protocol", $nsmgr)
$aea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias", $nsmgr)
$ea = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Applications/pkg:Application/pkg:Extensions/uap5:Extension[@Category='windows.appExecutionAlias']/uap5:AppExecutionAlias/uap5:ExecutionAlias", $nsmgr)

# Update the publisher
$xmlDoc.Package.Identity.Publisher = $Publisher

if ($Branch -eq "SideloadPreview")
{
# Set identities
$xmlDoc.Package.Identity.Name="FilesPreview"
$xmlDoc.Package.Properties.DisplayName="Files - Preview"
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files - Preview"
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files - Preview"

# Update app protocol and execution alias
$ap.SetAttribute("Name", "files-preview");
$ea.SetAttribute("Alias", "files-preview.exe");

# Save modified Package.appxmanifest
$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, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-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"

# Remove capability that is only used for the sideload package
$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)

# Update app protocol and execution alias
$ap.SetAttribute("Name", "files-preview");
$ea.SetAttribute("Alias", "files-preview.exe");

$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, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | `
Set-Content $_ -NoNewline `
}
}
elseif ($Branch -eq "SideloadStable")
{
# Set identities
$xmlDoc.Package.Identity.Name="Files"
$xmlDoc.Package.Properties.DisplayName="Files"
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files"

# Update app protocol and execution alias
$ap.SetAttribute("Name", "files-stable");
$ea.SetAttribute("Alias", "files-stable.exe");

# Save modified Package.appxmanifest
$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\Release" }) | `
Set-Content $_ -NoNewline `
}

Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
Set-Content $_ -NoNewline `
}
}
elseif ($Branch -eq "StoreStable")
{
# Set identities
$xmlDoc.Package.Identity.Name="49306atecsolution.FilesUWP"
$xmlDoc.Package.Properties.DisplayName="Files App"
$xmlDoc.Package.Applications.Application.VisualElements.DisplayName="Files"
$xmlDoc.Package.Applications.Application.VisualElements.DefaultTile.ShortName="Files"

# Remove capability that is only used for the sideload package
$pm = $xmlDoc.SelectSingleNode("/pkg:Package/pkg:Capabilities/rescap:Capability[@Name='packageManagement']", $nsmgr)
$xmlDoc.Package.Capabilities.RemoveChild($pm)

# Update app protocol and execution alias
$ap.SetAttribute("Name", "files-stable");
$ea.SetAttribute("Alias", "files-stable.exe");

# Save modified Package.appxmanifest
$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\Release" }) | `
Set-Content $_ -NoNewline `
}

Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
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 `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | `
Set-Content $_ -NoNewline `
}

Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
{
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | `
Set-Content $_ -NoNewline `
}

Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | `
Set-Content $_ -NoNewline `
}
81 changes: 28 additions & 53 deletions .github/scripts/Configure-AppxManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
param(
[string]$Branch = "", # This has to correspond with one of the AppEnvironment enum values
[string]$PackageManifestPath = "",
[string]$Publisher = "",
[string]$WorkingDir = "",
[string]$SecretBingMapsKey = "",
[string]$SecretSentry = "",
[string]$SecretGitHubOAuthClientId = ""
[string]$IsBuildingInVisualStudio = "false"
)

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

$IsBuildingInVisualStudio = [System.Convert]::ToBoolean($IsBuildingInVisualStudio)

# Update the publisher
$xmlDoc.Package.Identity.Publisher = $Publisher
#$xmlDoc.Package.Identity.Publisher = $Publisher

if ($Branch -eq "SideloadPreview")
{
Expand All @@ -41,18 +40,6 @@ if ($Branch -eq "SideloadPreview")

# Save modified Package.appxmanifest
$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, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | `
Set-Content $_ -NoNewline `
}
}
elseif ($Branch -eq "StorePreview")
{
Expand All @@ -77,14 +64,18 @@ elseif ($Branch -eq "StorePreview")

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-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Preview" })
if (!$IsBuildingInVisualStudio) {
Set-Content $_ -NoNewline
}
}

Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" }) | `
Set-Content $_ -NoNewline `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-preview" })
if (!$IsBuildingInVisualStudio) {
Set-Content $_ -NoNewline
}
}
}
elseif ($Branch -eq "SideloadStable")
Expand All @@ -104,14 +95,18 @@ elseif ($Branch -eq "SideloadStable")

Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
Set-Content $_ -NoNewline `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" })
if (!$IsBuildingInVisualStudio) {
Set-Content $_ -NoNewline
}
}

Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
Set-Content $_ -NoNewline `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" })
if (!$IsBuildingInVisualStudio) {
Set-Content $_ -NoNewline
}
}
}
elseif ($Branch -eq "StoreStable")
Expand All @@ -135,37 +130,17 @@ elseif ($Branch -eq "StoreStable")

Get-ChildItem $WorkingDir -Include *.csproj, *.appxmanifest, *.wapproj, *.xaml -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" }) | `
Set-Content $_ -NoNewline `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "Assets\\AppTiles\\Dev", "Assets\AppTiles\Release" })
if (!$IsBuildingInVisualStudio) {
Set-Content $_ -NoNewline
}
}

Get-ChildItem $WorkingDir -Include *.cs, *.cpp -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" }) | `
Set-Content $_ -NoNewline `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "files-dev", "files-stable" })
if (!$IsBuildingInVisualStudio) {
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 `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "bingmapskey.secret", "$SecretBingMapsKey" }) | `
Set-Content $_ -NoNewline `
}

Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
{
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "sentry.secret", "$SecretSentry" }) | `
Set-Content $_ -NoNewline `
}

Get-ChildItem $WorkingDir -Include *.cs -recurse | ForEach-Object -Process `
{ `
(Get-Content $_ -Raw | ForEach-Object -Process { $_ -replace "githubclientid.secret", "$SecretGitHubOAuthClientId" }) | `
Set-Content $_ -NoNewline `
}
30 changes: 30 additions & 0 deletions .github/scripts/Copy-AppTiles.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
param (
[string]$Channel, # Dev, Preview, or Stable
[string]$WorkingDir
)

# Define source and destination paths
$SourcePath = "$WorkingDir\src\Files.App\Assets\AppTiles\$Channel"
$DestinationPath = "$WorkingDir\src\Files.App\Assets\AppTiles\Current"

# Check if the source directory exists
if (-Not (Test-Path -Path $SourcePath)) {
Write-Host "Source path '$SourcePath' does not exist. Please check the branch name." -ForegroundColor Red
exit 1
}

# Ensure the destination directory exists
if (-Not (Test-Path -Path $DestinationPath)) {
Write-Host "Destination path '$DestinationPath' does not exist. Creating it now..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path $DestinationPath | Out-Null
} else {
# Delete the contents of the destination directory
Write-Host "Clearing contents of '$DestinationPath'..."
Get-ChildItem -Path $DestinationPath -Recurse | Remove-Item -Force -Recurse
}

# Copy files from source to destination
Write-Host "Copying files from '$SourcePath' to '$DestinationPath'..."
Copy-Item -Path "$SourcePath\*" -Destination $DestinationPath -Recurse -Force

Write-Host "Files copied successfully!" -ForegroundColor Green
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Files.App.OpenDialog*.dll
Files.App.SaveDialog*.dll
Files.App.Launcher.exe

src/Files.App/Assets/AppTiles/Current/

# User-specific files
*.rsuser
*.suo
Expand Down
40 changes: 33 additions & 7 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
<!-- Copyright (c) Files Community. Licensed under the MIT License. -->
<Project>
<PropertyGroup>
<TargetFrameworkVersion>net9.0</TargetFrameworkVersion>
<TargetWindowsVersion>10.0.22621.0</TargetWindowsVersion>
<MinimalWindowsVersion>10.0.19041.0</MinimalWindowsVersion>
<WindowsSdkPackageVersion>10.0.22621.57</WindowsSdkPackageVersion>
<WindowsTargetFramework>$(TargetFrameworkVersion)-windows$(TargetWindowsVersion)</WindowsTargetFramework>
</PropertyGroup>
<!-- Directories -->
<PropertyGroup>
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
<SourceDir>$(RootDir)\src</SourceDir>
<TestsDir>$(RootDir)\tests</TestsDir>
<BuildDir>$(RootDir)\eng</BuildDir>
<RepoDir>$(RootDir)\.github</RepoDir>

<AppXManifestProvider>$(BuildDir)\PackageManifest.props</AppXManifestProvider>
<AppXManifestGenerator>$(BuildDir)\MakeAppXManifest.targets</AppXManifestGenerator>
<AppXPackageProjectPath>$(SourceDir)\Files.App (Package)</AppXPackageProjectPath>
<AppXManifestFile>$(BuildDir)\Package.appxmanifest</AppXManifestFile>
</PropertyGroup>

<!-- Target framework -->
<PropertyGroup>
<TargetFrameworkVersion>net9.0</TargetFrameworkVersion>
<TargetWindowsVersion>10.0.22621.0</TargetWindowsVersion>
<MinimalWindowsVersion>10.0.19041.0</MinimalWindowsVersion>
<WindowsSdkPackageVersion>10.0.22621.57</WindowsSdkPackageVersion>
<WindowsTargetFramework>$(TargetFrameworkVersion)-windows$(TargetWindowsVersion)</WindowsTargetFramework>
</PropertyGroup>

<!-- App environment -->
<PropertyGroup>
<AppEnvironment>$(Configuration)</AppEnvironment>
<ConfigurationCallName Condition="'$(AppEnvironment)' == 'Dev'">Debug</ConfigurationCallName>
<ConfigurationCallName Condition="'$(AppEnvironment)' != 'Dev'">Release</ConfigurationCallName>

<AppChannel Condition="$(AppEnvironment.Contains('Stable'))">Stable</AppChannel>
<AppChannel Condition="$(AppEnvironment.Contains('Preview'))">Preview</AppChannel>
<AppChannel Condition="$(AppEnvironment.Contains('Dev'))">Dev</AppChannel>
</PropertyGroup>
</Project>
Loading
Loading