Skip to content

Commit 6759aa2

Browse files
committed
fix(windows): avoid ActionPreferenceStopException during native compilation and run scripts directly
1 parent 1e8154d commit 6759aa2

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
if: runner.os == 'Windows'
8585
shell: powershell
8686
run: |
87-
powershell -ExecutionPolicy Bypass -File scripts/windows/build-launcher.ps1 -Strict
87+
& .\scripts\windows\build-launcher.ps1 -Strict
8888
if (-not (Test-Path "bin/opencode-vpn.exe")) {
8989
throw "Native launcher compilation failed: bin/opencode-vpn.exe not found"
9090
}
@@ -94,7 +94,7 @@ jobs:
9494
if: runner.os == 'Windows'
9595
shell: powershell
9696
run: |
97-
powershell -ExecutionPolicy Bypass -File scripts/windows/check-environment.ps1
97+
& .\scripts\windows\check-environment.ps1
9898
npm run package:portable
9999
# Test extraction in clean directory
100100
$pkg = Get-ChildItem dist-release/*.zip | Select-Object -First 1
@@ -112,6 +112,6 @@ jobs:
112112
if: runner.os == 'Windows'
113113
shell: powershell
114114
run: |
115-
powershell -ExecutionPolicy Bypass -File scripts/windows/verify-release.ps1
115+
& .\scripts\windows\verify-release.ps1
116116
Write-Host "Native Windows verification kit passed."
117117
Write-Host "NOTE: Windows ARM64 target matrix remains IMPLEMENTED BUT UNVERIFIED on real ARM64 hardware."

‎scripts/windows/build-launcher.ps1‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,21 @@ foreach ($candidate in $cscCandidates) {
5050

5151
if ($cscPath) {
5252
Write-Host "🔨 Compiling native launcher with $cscPath..." -ForegroundColor Cyan
53-
$compileOutput = & "$cscPath" /nologo /optimize+ /target:exe "/out:$outputExe" "$sourceFile" 2>&1
54-
Write-Host ($compileOutput | Out-String)
55-
if ($LASTEXITCODE -eq 0 -and (Test-Path $outputExe)) {
53+
$oldEap = $ErrorActionPreference
54+
$ErrorActionPreference = 'Continue'
55+
& "$cscPath" /nologo /optimize+ /target:exe "/out:$outputExe" "$sourceFile"
56+
$code = $LASTEXITCODE
57+
$ErrorActionPreference = $oldEap
58+
59+
if ($code -eq 0 -and (Test-Path $outputExe)) {
5660
Write-Host "✅ Native Windows launcher built successfully: $outputExe" -ForegroundColor Green
5761
exit 0
5862
} else {
5963
if ($Strict -or $env:OPENCODE_REQUIRE_NATIVE_LAUNCHER -eq "1") {
60-
throw "Failed to compile $outputExe (ExitCode: $LASTEXITCODE). Output: $compileOutput"
64+
throw "Failed to compile $outputExe (ExitCode: $code)"
6165
}
62-
Write-Error "Failed to compile $outputExe (ExitCode: $LASTEXITCODE)"
66+
Write-Error "Failed to compile $outputExe (ExitCode: $code)"
67+
exit $code
6368
}
6469
} else {
6570
# Fallback to dotnet if available

0 commit comments

Comments
 (0)