Files
CommandForge/scripts/pack.ps1
T
poli0981andClaude Opus 5.5 66415bbd61 build(release): pin vpk as a local tool, ReadyToRun publish, native x64 Velopack helpers
- .config/dotnet-tools.json pins vpk 1.2.161 to match the Velopack library (CI previously installed
  whatever vpk was latest).
- pack.ps1: ReadyToRun publish for faster startup, fail fast on any non-zero exit code, verify
  the Elevator is in the publish folder, `-SkipPack` for publish-only runs, and `--runtime` so vpk
  bundles x64 Update/Setup helpers instead of defaulting to x86 (the update channel stays "win").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 19:56:43 +07:00

89 lines
3.2 KiB
PowerShell

#requires -Version 7
<#
.SYNOPSIS
Publishes CommandForge self-contained and packages it with Velopack (vpk) for GitHub Releases.
.DESCRIPTION
Produces, under Releases/:
CommandForge-win-Setup.exe, RELEASES, releases.win.json, *-full.nupkg, *-delta.nupkg
Update is per-user (no UAC). The Elevator is published into the same folder by the
PublishElevatorOnPublish MSBuild target, so vpk packages it automatically.
vpk is pinned as a local .NET tool (.config/dotnet-tools.json) and must match the Velopack
library version in Directory.Packages.props.
.PARAMETER Version
SemVer package version, e.g. 2.0.0 (no leading 'v'). Should match the git tag vX.Y.Z.
.PARAMETER SkipPack
Publish only (no vpk pack) — used by the CI packaging smoke test when vpk is not wanted.
.EXAMPLE
./scripts/pack.ps1 -Version 2.0.0
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string] $Version,
[string] $Runtime = 'win-x64',
[string] $Configuration = 'Release',
[switch] $SkipPack
)
$ErrorActionPreference = 'Stop'
$repoRoot = Split-Path -Parent $PSScriptRoot
$publishDir = Join-Path $repoRoot "publish/$Runtime"
$wpfProject = Join-Path $repoRoot 'src/CommandForge.Wpf'
Write-Host "Publishing CommandForge $Version ($Runtime, $Configuration)..." -ForegroundColor Cyan
# Stamp the assembly version so the in-app "App version" (Settings -> About, Report Bug) matches
# the released package version. ReadyToRun precompiles the app's own assemblies for faster startup
# (the self-contained framework assemblies are already precompiled).
dotnet publish $wpfProject `
-c $Configuration -r $Runtime --self-contained true `
-p:PublishSingleFile=false `
-p:PublishReadyToRun=true `
-p:Version=$Version -p:FileVersion=$Version -p:InformationalVersion=$Version `
-o $publishDir
if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed with exit code $LASTEXITCODE" }
# The elevated helper must ship next to the app (BrokerElevationService spawns it from there).
foreach ($file in 'CommandForge.Wpf.exe', 'CommandForge.Elevator.exe', 'CommandForge.Elevator.dll') {
if (-not (Test-Path (Join-Path $publishDir $file))) {
throw "Publish output is missing $file"
}
}
if ($SkipPack) {
Write-Host "Publish OK (pack skipped). Output: $publishDir" -ForegroundColor Green
return
}
Push-Location $repoRoot
try {
dotnet tool restore
if ($LASTEXITCODE -ne 0) { throw "dotnet tool restore failed with exit code $LASTEXITCODE" }
Write-Host "Packing with Velopack..." -ForegroundColor Cyan
# --runtime selects native x64 Update.exe/Setup.exe helpers (vpk otherwise defaults to x86);
# the update channel stays the default "win", so existing installs keep receiving updates.
dotnet vpk pack `
--runtime $Runtime `
--packId CommandForge `
--packTitle CommandForge `
--packAuthors poli0981 `
--packVersion $Version `
--packDir $publishDir `
--mainExe CommandForge.Wpf.exe
if ($LASTEXITCODE -ne 0) { throw "vpk pack failed with exit code $LASTEXITCODE" }
}
finally {
Pop-Location
}
Write-Host "Done. Artifacts are in $(Join-Path $repoRoot 'Releases')." -ForegroundColor Green