modified layout (#2)

Reviewed-on: #2
Co-authored-by: Aleksandr Neychev <alexnejchev73@gmail.com>
This commit was merged in pull request #2.
This commit is contained in:
2026-08-12 14:25:05 +00:00
committed by alex
parent 55ac8e6556
commit 68b3d544d2
14 changed files with 376 additions and 415 deletions
+66
View File
@@ -18,10 +18,19 @@
section. It is handed out there together with the reserved application name;
the default is only good enough for a check on your own machine.
.PARAMETER Install
Puts the package onto this machine to see it working. Developer mode has to
be on; a signature is not needed, because what gets registered is the layout
the package is made of rather than the package file.
.EXAMPLE
# A check on your own machine: your architecture alone
pwsh -File Packaging\build-msix.ps1 -Architectures x64
.EXAMPLE
# Build and install in one go, to click through the application
pwsh -File Packaging\build-msix.ps1 -Architectures x64 -Install
.EXAMPLE
# A build for the Store — the identity comes from Partner Center
pwsh -File Packaging\build-msix.ps1 -Version 1.0.1.0 `
@@ -39,6 +48,8 @@ param(
[ValidateSet('x64', 'arm64')]
[string[]] $Architectures = @('x64', 'arm64'),
[switch] $Install,
[string] $OutputPath
)
@@ -65,6 +76,25 @@ if (-not (Test-Path $assets)) {
throw "No logos found in '$assets'. Run Packaging\New-Assets.ps1 first."
}
if ($Install) {
# Both things below are checked before the build rather than after it: the
# build takes minutes, and neither of them gets any truer while it runs
$developerMode = Get-ItemPropertyValue `
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock' `
-Name 'AllowDevelopmentWithoutDevLicense' -ErrorAction SilentlyContinue
if ($developerMode -ne 1) {
throw 'Installing needs developer mode: Settings - System - For developers - Developer mode. Without a signature Windows registers a package no other way.'
}
$machineArchitecture = if ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture -eq 'Arm64') { 'arm64' } else { 'x64' }
if ($Architectures -notcontains $machineArchitecture) {
throw "This machine is $machineArchitecture, and that architecture is not being built. Add it to -Architectures, or drop -Install."
}
}
function Invoke-Tool {
<#
.SYNOPSIS
@@ -136,6 +166,26 @@ Invoke-Tool -Path 'dotnet' -Arguments @('restore', $toolsProject, '--nologo')
$sdkTools = Get-SdkToolsPath
$makeappx = Get-SdkTool -Name 'makeappx.exe' -PackagePath $sdkTools
# A package registered out of the layout runs straight from that folder, and
# the folder is about to be wiped. Left in place, the registration would point
# at files that are gone — an application that neither starts nor uninstalls
# the usual way. This happens whatever the build was asked for, so -Install has
# no say in it.
#
# Only a registration made from this very folder is removed. A copy installed
# from the Store answers to the same name and is none of our business
foreach ($installed in @(Get-AppxPackage -Name $IdentityName)) {
$location = $installed.InstallLocation
if (-not $location) { continue }
if (-not $location.TrimEnd('\').StartsWith($layoutRoot.TrimEnd('\'), [StringComparison]::OrdinalIgnoreCase)) {
continue
}
Write-Host "Removing the registered $($installed.PackageFullName)..." -ForegroundColor Cyan
Remove-AppxPackage -Package $installed.PackageFullName
}
Remove-Item $layoutRoot -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $packagesPath -Force | Out-Null
@@ -198,9 +248,25 @@ if ($built.Count -gt 1) {
Remove-Item $bundleInput -Recurse -Force
}
if ($Install) {
Write-Host "Installing the $machineArchitecture build..." -ForegroundColor Cyan
# The layout is registered rather than the package file: the two hold the
# same thing, but a package file Windows only installs when it is signed
Add-AppxPackage -Register (Join-Path $layoutRoot "$machineArchitecture\AppxManifest.xml")
}
Write-Host ''
Write-Host 'Done.' -ForegroundColor Green
Write-Host " $result"
Write-Host ''
Write-Host ' This file is uploaded to Partner Center as it is.'
if ($Install) {
Write-Host ''
Write-Host ' The application is installed and runs out of the layout folder, so'
Write-Host ' building again would pull the files out from under it. This script'
Write-Host ' takes care of that itself; to remove the application by hand:'
Write-Host " Remove-AppxPackage (Get-AppxPackage -Name $IdentityName).PackageFullName"
}