@@ -154,7 +154,46 @@ jobs:
154154 run: cd frontend && npx vue-tsc --noEmit
155155
156156 - name: Install NSIS
157- run: choco install nsis -y
157+ shell: pwsh
158+ run: |
159+ # Chocolatey 社区源偶发 5xx(choco 遇 503/504 会"装 0 个包"但仍退出 0),
160+ # 因此一律以"makensis 是否真的存在"为准,并层层兜底:
161+ # 已预装 → 重试 choco → 直接下载官方便携版
162+ function Find-NsisDir {
163+ foreach ($p in @("C:\Program Files (x86)\NSIS\makensis.exe", "C:\Program Files\NSIS\makensis.exe")) {
164+ if (Test-Path $p) { return (Split-Path $p) }
165+ }
166+ $cmd = Get-Command makensis -ErrorAction SilentlyContinue
167+ if ($cmd) { return (Split-Path $cmd.Source) }
168+ return $null
169+ }
170+ # 把发现的目录导出到后续步骤的 PATH,兼容 choco/预装/便携版各种落点
171+ function Publish-Nsis($dir) {
172+ Add-Content -Path $env:GITHUB_PATH -Value $dir
173+ Write-Host "NSIS 目录已加入 PATH: $dir"
174+ }
175+
176+ $dir = Find-NsisDir
177+ if ($dir) { Publish-Nsis $dir; exit 0 }
178+
179+ for ($i = 1; $i -le 3; $i++) {
180+ Write-Host "choco install nsis 第 $i 次尝试"
181+ choco install nsis -y --no-progress
182+ $dir = Find-NsisDir
183+ if ($dir) { Publish-Nsis $dir; exit 0 }
184+ Write-Host "第 $i 次未成功(源可能暂不可用),20s 后重试"
185+ Start-Sleep -Seconds 20
186+ }
187+
188+ Write-Host "choco 持续不可用,回退到官方便携版直接下载"
189+ $ver = "3.10"
190+ $zip = Join-Path $env:RUNNER_TEMP "nsis.zip"
191+ $dest = "C:\nsis-portable"
192+ Invoke-WebRequest -Uri "https://prdownloads.sourceforge.net/nsis/nsis-$ver.zip?download" -OutFile $zip -UseBasicParsing
193+ Expand-Archive -Path $zip -DestinationPath $dest -Force
194+ $makensis = Get-ChildItem -Path $dest -Recurse -Filter makensis.exe | Select-Object -First 1
195+ if (-not $makensis) { throw "NSIS 便携版下载/解压失败,未找到 makensis.exe" }
196+ Publish-Nsis (Split-Path $makensis.FullName)
158197
159198 - name: Update build assets
160199 run: wails3 task common:update:build-assets
0 commit comments