locally build installer.exe

This commit is contained in:
Kai Tao (from Dev Box)
2025-12-05 17:50:50 +08:00
parent 52f2561937
commit d975380d31

View File

@@ -3,14 +3,7 @@
Build and package PowerToys (CmdPal and installer) for a specific platform and configuration LOCALLY.
.DESCRIPTION
This script automates the end-to-end build and packaging process for PowerToys, including:
- Restoring and building all necessary solutions (CmdPal, BugReportTool, etc.)
- Cleaning up old output
- Signing generated .msix packages
- Building the WiX v5 (VNext) MSI and bootstrapper installers
It is designed to work in local development.
The cert used to sign the packages is generated by
Builds and packages PowerToys (CmdPal and installer) locally. Handles solution build, signing, and WiX installer generation.
.PARAMETER Platform
Specifies the target platform for the build (e.g., 'arm64', 'x64'). Default is 'x64'.
@@ -45,11 +38,23 @@ Runs the pipeline for x64 Release with machine-wide installer.
#>
param (
[string]$Platform = '',
[string]$Platform = 'x64',
[string]$Configuration = 'Release',
[string]$PerUser = 'true'
[string]$PerUser = 'true',
[switch]$Clean,
[switch]$Help
)
if ($Help) {
Write-Host "Usage: .\build-installer.ps1 [-Platform <x64|arm64>] [-Configuration <Release|Debug>] [-PerUser <true|false>] [-Clean]"
Write-Host " -Platform Target platform (default: auto-detect or x64)"
Write-Host " -Configuration Build configuration (default: Release)"
Write-Host " -PerUser Build per-user installer (default: true)"
Write-Host " -Clean Clean output directories before building"
Write-Host " -Help Show this help message"
exit 0
}
# Ensure helpers are available
. "$PSScriptRoot\build-common.ps1"
@@ -94,13 +99,33 @@ Write-Host ("[PIPELINE] Start | Platform={0} Configuration={1} PerUser={2}" -f $
Write-Host ''
$cmdpalOutputPath = Join-Path $repoRoot "$Platform\$Configuration\WinUI3Apps\CmdPal"
$buildOutputPath = Join-Path $repoRoot "$Platform\$Configuration"
if ($Clean) {
if (Test-Path $cmdpalOutputPath) {
Write-Host "[CLEAN] Removing previous output: $cmdpalOutputPath"
Remove-Item $cmdpalOutputPath -Recurse -Force -ErrorAction Ignore
}
if (Test-Path $buildOutputPath) {
Write-Host "[CLEAN] Removing previous build output: $buildOutputPath"
Remove-Item $buildOutputPath -Recurse -Force -ErrorAction Ignore
}
$commonArgs = '/p:CIBuild=true'
Write-Host "[CLEAN] Cleaning all build artifacts (git clean -Xfd)..."
Push-Location $repoRoot
try {
git clean -Xfd | Out-Null
} catch {
Write-Warning "[CLEAN] git clean failed: $_"
} finally {
Pop-Location
}
Write-Host "[CLEAN] Cleaning solution (msbuild /t:Clean)..."
RunMSBuild 'PowerToys.slnx' '/t:Clean' $Platform $Configuration
}
$commonArgs = '/p:CIBuild=true /p:IsPipeline=true'
# No local projects found (or continuing) - build full solution and tools
RestoreThenBuild 'PowerToys.slnx' $commonArgs $Platform $Configuration
@@ -133,6 +158,7 @@ if (Test-Path $dscScriptPath) {
RestoreThenBuild 'tools\BugReportTool\BugReportTool.sln' $commonArgs $Platform $Configuration
RestoreThenBuild 'tools\StylesReportTool\StylesReportTool.sln' $commonArgs $Platform $Configuration
if ($Clean) {
Write-Host '[CLEAN] installer (keep *.exe)'
Push-Location $repoRoot
try {
@@ -140,11 +166,23 @@ try {
} finally {
Pop-Location
}
}
RunMSBuild 'installer\PowerToysSetup.slnx' "$commonArgs /t:restore /p:RestorePackagesConfig=true" $Platform $Configuration
RunMSBuild 'installer\PowerToysSetup.slnx' "$commonArgs /m /t:PowerToysInstallerVNext /p:PerUser=$PerUser" $Platform $Configuration
# Fix: WiX v5 locally puts the MSI in an 'en-us' subfolder, but the Bootstrapper expects it in the root of UserSetup/MachineSetup.
# We move it up one level to match expectations.
$setupType = if ($PerUser -eq 'true') { 'UserSetup' } else { 'MachineSetup' }
$msiParentDir = Join-Path $repoRoot "installer\PowerToysSetupVNext\$Platform\$Configuration\$setupType"
$msiEnUsDir = Join-Path $msiParentDir "en-us"
if (Test-Path $msiEnUsDir) {
Write-Host "[FIX] Moving MSI files from $msiEnUsDir to $msiParentDir"
Get-ChildItem -Path $msiEnUsDir -Filter *.msi | Move-Item -Destination $msiParentDir -Force
}
RunMSBuild 'installer\PowerToysSetup.slnx' "$commonArgs /m /t:PowerToysBootstrapperVNext /p:PerUser=$PerUser" $Platform $Configuration
Write-Host '[PIPELINE] Completed'