From bd0ca28bb0186ec8e74b53862763949fabbf71cb Mon Sep 17 00:00:00 2001 From: draco892 Date: Tue, 13 Oct 2026 12:00:04 +0200 Subject: [PATCH] build: fix host architecture detection in Windows PowerShell 5.1 Use Windows environment variables instead of RuntimeInformation to avoid a null value during the final CLI smoke test. Account for emulated shells using PROCESSOR_ARCHITEW6432. --- packaging/windows/package.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packaging/windows/package.ps1 b/packaging/windows/package.ps1 index 27e0f0a03..24101e707 100644 --- a/packaging/windows/package.ps1 +++ b/packaging/windows/package.ps1 @@ -167,7 +167,15 @@ Compress-Archive -Path $Portable -DestinationPath $Zip # Smoke-test the CLI when this machine can run it. An ARM64 build made on an x64 runner can't run # here; .github/workflows/windows-arm64.yml installs and runs it on ARM64 instead. -$HostArch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture.ToString().ToLowerInvariant() +# Windows PowerShell 5.1 can expose OSArchitecture as null. Use Windows' environment +# variables instead; PROCESSOR_ARCHITEW6432 identifies the OS when the shell is emulated. +$nativeArchitecture = if ($env:PROCESSOR_ARCHITEW6432) { $env:PROCESSOR_ARCHITEW6432 } else { $env:PROCESSOR_ARCHITECTURE } +$HostArch = switch ($nativeArchitecture) { + 'AMD64' { 'x64' } + 'x86' { 'x86' } + 'ARM64' { 'arm64' } + default { 'unknown' } +} if ($Arch -ne 'arm64' -or $HostArch -eq 'arm64') { Invoke-Native 'lightcraft-cli --version' { & (Join-Path $Stage 'lightcraft-cli.exe') --version } } else {