param( [string]$BuildDir = "$PSScriptRoot\..\..\build", [string]$DistDir = "$PSScriptRoot\..\..\dist\windows" ) $ErrorActionPreference = "Stop" $cacheFile = Join-Path $BuildDir "CMakeCache.txt" if (-not (Test-Path $cacheFile)) { throw "Build directory not configured: $BuildDir (run cmake -S . -B build first)" } $versionLine = Select-String -Path $cacheFile -Pattern '^CMAKE_PROJECT_VERSION:STATIC=(.*)$' if (-not $versionLine) { throw "Unable to determine project version from $cacheFile" } $version = $versionLine.Matches[0].Groups[1].Value $isccCandidates = @( "C:\Program Files (x86)\Inno Setup 6\ISCC.exe", "C:\Program Files\Inno Setup 6\ISCC.exe", "$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe" ) $iscc = $isccCandidates | Where-Object { Test-Path $_ } | Select-Object -First 1 if (-not $iscc) { throw "Inno Setup compiler (ISCC.exe) not found. Install it: winget install -e --id JRSoftware.InnoSetup" } New-Item -ItemType Directory -Force -Path $DistDir | Out-Null & $iscc "/DMyAppVersion=$version" "$PSScriptRoot\orbithub.iss" if ($LASTEXITCODE -ne 0) { throw "ISCC.exe failed with exit code $LASTEXITCODE" } Write-Output "Created $DistDir\OrbitHub-Setup-$version.exe"