diff --git a/packaging/windows/build-installer.ps1 b/packaging/windows/build-installer.ps1 index 224275719..e5a98f526 100644 --- a/packaging/windows/build-installer.ps1 +++ b/packaging/windows/build-installer.ps1 @@ -55,10 +55,32 @@ if (-not $iscc) { $iscc = Find-Iscc if (-not $iscc) { throw 'winget finished but ISCC.exe was not found. Install Inno Setup 6 from https://jrsoftware.org/isdl.php and run again.' } } -$isccVersion = (Get-Item $iscc).VersionInfo.FileVersion -Say "Inno Setup $isccVersion at $iscc" -$v = [Version]($isccVersion -replace '[^0-9.].*$', '') -if ($v -lt [Version]'6.3.0') { throw "Inno Setup $isccVersion is too old; 6.3 or newer is needed (winget upgrade --id JRSoftware.InnoSetup)." } +# The version: ISCC.exe's own file version first; some installs (the GitHub runner image) ship an ISCC.exe without a +# version block (0.0.0.0), then the uninstall key's DisplayVersion or ISCmplr.dll next to it. Unknown = continue. +function Get-IsccVersion([string]$exe) { + $candidates = @((Get-Item $exe).VersionInfo.FileVersion, (Get-Item $exe).VersionInfo.ProductVersion) + foreach ($key in @('HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1', + 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1', + 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Inno Setup 6_is1')) { + try { $candidates += (Get-ItemProperty -Path $key -ErrorAction Stop).DisplayVersion } catch { } + } + $dll = Join-Path (Split-Path -Parent $exe) 'ISCmplr.dll' + if (Test-Path $dll) { $candidates += (Get-Item $dll).VersionInfo.FileVersion } + foreach ($c in $candidates) { + if (-not $c) { continue } + $clean = ($c -replace '[^0-9.].*$', '') + try { $v = [Version]$clean } catch { continue } + if ($v.Major -gt 0) { return $v } + } + return $null +} +$v = Get-IsccVersion $iscc +if ($v) { + Say "Inno Setup $v at $iscc" + if ($v -lt [Version]'6.3.0') { throw "Inno Setup $v is too old; 6.3 or newer is needed (winget upgrade --id JRSoftware.InnoSetup)." } +} else { + Say "Inno Setup at $iscc (version unknown: no version block, no uninstall key; continuing)" +} # ---- 2. the art ------------------------------------------------------------------------------------------------------ $art = $null