From c86d2363c1f95f48a1c9b1741df5bf4315b4a831 Mon Sep 17 00:00:00 2001 From: Justin Paul Date: Fri, 8 May 2026 13:35:34 -0400 Subject: [PATCH] Sync .NET cwd, bake version into temp .iss, pass /O absolute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous run produced "The system cannot find the path specified." with exit 2 right after ISCC's banner — ISPP loaded fine (Martijn Laan copyright printed) but then 200ms of work and silent path failure. Three changes to isolate/fix: - Sync `[System.IO.Directory]::SetCurrentDirectory` alongside Push-Location. PowerShell's Push-Location updates the PSDrive location but not the .NET process cwd that native exes inherit, so ISCC may have been resolving `..\dist` against the wrong dir. - Bake AppVersion into a temp `.gen.iss` instead of passing `/DAppVersion=...`, removing /D from the equation. - Pass `/O` so OutputDir resolution doesn't depend on cwd at all. Also dumps the iscc log file contents and prints PS-vs-.NET cwd before and after Push-Location so the next run shows whether the divergence was real. --- scripts/build-installer.ps1 | 46 ++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/scripts/build-installer.ps1 b/scripts/build-installer.ps1 index 30da608..f0717e4 100644 --- a/scripts/build-installer.ps1 +++ b/scripts/build-installer.ps1 @@ -118,17 +118,57 @@ foreach ($ref in $issRefs) { } Write-Host "" +Write-Host "--- runtime context ---" -ForegroundColor Cyan +Write-Host " whoami: $(whoami)" +Write-Host " USERPROFILE: $env:USERPROFILE" +Write-Host " APPDATA: $env:APPDATA" +Write-Host " LOCALAPPDATA: $env:LOCALAPPDATA" +Write-Host " TEMP: $env:TEMP" +$isccDir = Split-Path $iscc -Parent +Write-Host " ISCC dir: $isccDir" +foreach ($f in @('ISCC.exe','ISCmplr.dll','ISPP.dll','Default.isl','Compil32.exe')) { + $p = Join-Path $isccDir $f + Write-Host (" {0,-15} exists={1}" -f $f, (Test-Path $p)) +} +Write-Host "" + +Write-Host " PS location (pre): $((Get-Location).Path)" +Write-Host " .NET cwd (pre): $([System.IO.Directory]::GetCurrentDirectory())" + Push-Location $issDir +$savedDotNetCwd = [System.IO.Directory]::GetCurrentDirectory() +[System.IO.Directory]::SetCurrentDirectory($issDir) try { - Write-Host " cwd=$issDir" + Write-Host " PS location (post): $((Get-Location).Path)" + Write-Host " .NET cwd (post): $([System.IO.Directory]::GetCurrentDirectory())" + + # Bake the version into a temp .iss and override OutputDir to an absolute + # path so nothing in the build depends on cwd resolution. + $tempIss = Join-Path $issDir "webhook-server.gen.iss" + $issBody = Get-Content $issName -Raw + $pattern = '(?s)#ifndef AppVersion\s+#define AppVersion "[^"]*"\s+#endif' + if ($issBody -notmatch $pattern) { throw "Could not find #ifndef AppVersion block in $issName" } + $issBody = $issBody -replace $pattern, "#define AppVersion `"$version`"" + Set-Content -Path $tempIss -Value $issBody -Encoding ascii + Write-Host " using $tempIss" + # Capture stdout+stderr together so any error line ISCC emits is visible # in the runner log even if the runner's console capture drops one stream. + # /O overrides OutputDir so ..\dist isn't resolved relative to + # whatever cwd ISCC actually inherits. $logPath = Join-Path $env:TEMP "iscc-$version.log" - & $iscc "/DAppVersion=$version" $issName *>&1 | Tee-Object -FilePath $logPath | ForEach-Object { Write-Host $_ } + & $iscc "/O$dist" (Split-Path $tempIss -Leaf) *>&1 | Tee-Object -FilePath $logPath | ForEach-Object { Write-Host $_ } $exit = $LASTEXITCODE Write-Host " ISCC exit code: $exit" - Write-Host " ISCC log: $logPath" + Write-Host " ISCC log path: $logPath" + if (Test-Path $logPath) { + Write-Host " --- iscc log file contents ---" + Get-Content $logPath | ForEach-Object { Write-Host " $_" } + Write-Host " --- end iscc log ---" + } + Remove-Item $tempIss -ErrorAction SilentlyContinue } finally { + [System.IO.Directory]::SetCurrentDirectory($savedDotNetCwd) Pop-Location } if ($exit -ne 0) { throw "Inno Setup compile failed (exit $exit)" }