Skip to content

Commit b620410

Browse files
committed
ci: locate swift.exe after winget install in Windows spike
1 parent 9e8b372 commit b620410

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎.github/workflows/windows-spike.yml‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,22 @@ jobs:
2323
run: |
2424
winget install --id Swift.Toolchain -e --source winget `
2525
--accept-source-agreements --accept-package-agreements
26-
$swiftBin = Join-Path $env:LOCALAPPDATA 'Programs\Swift\bin'
27-
if (-not (Test-Path $swiftBin)) {
28-
$swiftBin = 'C:\Swift\bin'
26+
$candidates = @(
27+
(Join-Path $env:LOCALAPPDATA 'Programs\Swift\bin'),
28+
'C:\Swift\bin',
29+
(Join-Path $env:LOCALAPPDATA 'Microsoft\WinGet\Packages')
30+
)
31+
$swiftBin = $null
32+
foreach ($c in $candidates) {
33+
if (Test-Path (Join-Path $c 'swift.exe')) { $swiftBin = $c; break }
2934
}
35+
if (-not $swiftBin) {
36+
$found = Get-ChildItem $env:LOCALAPPDATA,'C:\' -Recurse -Filter 'swift.exe' `
37+
-ErrorAction SilentlyContinue -Depth 5 | Select-Object -First 1
38+
if ($found) { $swiftBin = $found.DirectoryName }
39+
}
40+
if (-not $swiftBin) { throw 'swift.exe not found after winget install' }
41+
Write-Host "Found swift at: $swiftBin"
3042
Add-Content $env:GITHUB_PATH $swiftBin
3143
3244
- name: Set up MSVC environment

0 commit comments

Comments
 (0)