Skip to content

Commit 9c3493f

Browse files
committed
Fix MSI detection: use recursive search and kill devenv by name
1 parent b564fd3 commit 9c3493f

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

.github/workflows/release.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -209,46 +209,44 @@ jobs:
209209
timeout-minutes: 10
210210
shell: pwsh
211211
run: |
212-
# 260405Cl devenv.com はテレメトリ(Chrome/GCM)が終了せずハングするため
213-
# バックグラウンドで起動し MSI 出現を監視して強制終了する。
212+
# 260405Cl devenv.com は .exe を別プロセスで起動して即終了し
213+
# さらにテレメトリ(Chrome/GCM)でハングするため、MSI 出現を監視して強制終了する。
214214
$devenvExe = (& "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -property productPath).Trim()
215215
if (-not $devenvExe) { throw "Visual Studio was not found." }
216216
217217
$devenvCli = [System.IO.Path]::ChangeExtension($devenvExe, ".com")
218218
if (-not (Test-Path $devenvCli)) { throw "devenv.com was not found next to $devenvExe." }
219219
220220
$buildLogPath = Join-Path $env:RUNNER_TEMP "devenv-build.log"
221-
$msiPath = "ReciProSetup\Release\ReciProSetup.msi"
222221
223-
# devenv をバックグラウンド起動
224-
$proc = Start-Process -FilePath $devenvCli -ArgumentList "`"${{ steps.pack_solution.outputs.solution_path }}`" /Build `"Release|x64`" /Project `"ReciProSetup`" /Out `"$buildLogPath`"" -PassThru -NoNewWindow
222+
# devenv をバックグラウンド起動 (devenv.com は .exe を spawn して即終了するため戻り値に依存しない)
223+
Start-Process -FilePath $devenvCli -ArgumentList "`"${{ steps.pack_solution.outputs.solution_path }}`" /Build `"Release|x64`" /Project `"ReciProSetup`" /Out `"$buildLogPath`""
225224
226-
# MSI が生成されるか、devenv が自力で終了するまで待機 (最大5分)
225+
# MSI を再帰検索で待機 (出力先が vdproj 設定に依存するため固定パスを使わない)
227226
$deadline = (Get-Date).AddMinutes(5)
228-
while (-not $proc.HasExited -and (Get-Date) -lt $deadline) {
229-
if (Test-Path $msiPath) {
230-
Write-Host "MSI detected, waiting 10s for post-build events..."
231-
Start-Sleep -Seconds 10
227+
$msiFile = $null
228+
while ((Get-Date) -lt $deadline) {
229+
$msiFile = Get-ChildItem -Path "ReciProSetup" -Filter "ReciProSetup.msi" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
230+
if ($msiFile) {
231+
Write-Host "MSI detected at $($msiFile.FullName), waiting 15s for post-build events..."
232+
Start-Sleep -Seconds 15
232233
break
233234
}
234-
Start-Sleep -Seconds 2
235+
Start-Sleep -Seconds 3
235236
}
236237
237-
# devenv がまだ生きていたら強制終了
238-
if (-not $proc.HasExited) {
239-
Write-Host "Stopping devenv (pid $($proc.Id)) to avoid telemetry hang..."
240-
Stop-Process -Id $proc.Id -Force -ErrorAction SilentlyContinue
241-
Start-Sleep -Seconds 2
242-
}
238+
# devenv 関連プロセスを全て強制終了
239+
Get-Process -Name devenv -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
240+
Start-Sleep -Seconds 2
243241
244242
if (Test-Path $buildLogPath) {
245243
Get-Content $buildLogPath
246244
}
247245
248-
if (-not (Test-Path $msiPath)) {
246+
if (-not $msiFile) {
249247
throw "MSI was not produced within the time limit."
250248
}
251-
Write-Host "MSI built successfully: $msiPath"
249+
Write-Host "MSI built successfully: $($msiFile.FullName)"
252250
253251
"build_exit_code=0" >> $env:GITHUB_OUTPUT
254252
"build_log_path=$buildLogPath" >> $env:GITHUB_OUTPUT

0 commit comments

Comments
 (0)