ci(windows): robust MSBuild discovery via vswhere with fallbacks
build-windows / build-windows-x64 (push) Failing after 1h35m15s
build-windows / build-windows-x64 (push) Failing after 1h35m15s
This commit is contained in:
@@ -381,10 +381,42 @@ jobs:
|
||||
python preprocess.py --arp -d ..\..\rustdesk -v "${env:VERSION_BASE}"
|
||||
|
||||
# Resolve MSBuild from the installed VS Build Tools.
|
||||
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
$msbuild = & $vswhere -latest -requires Microsoft.Component.MSBuild `
|
||||
# Resolve vswhere.exe explicitly. ${env:ProgramFiles(x86)} interpolation
|
||||
# has parser-version quirks; use [Environment] to avoid them.
|
||||
$pfx86 = [Environment]::GetEnvironmentVariable('ProgramFiles(x86)')
|
||||
$vswhere = Join-Path $pfx86 'Microsoft Visual Studio\Installer\vswhere.exe'
|
||||
if (-not (Test-Path $vswhere)) {
|
||||
throw "vswhere.exe not found at $vswhere -- VS Installer missing?"
|
||||
}
|
||||
Write-Host "vswhere: $vswhere"
|
||||
|
||||
# Diagnostic: show what VS installs vswhere can see.
|
||||
Write-Host "`n== vswhere installations =="
|
||||
& $vswhere -all -prerelease -products '*' -property installationPath
|
||||
Write-Host "==="
|
||||
|
||||
# Try the targeted -requires first; fall back to a broader search if the
|
||||
# component name doesn't match (e.g. on Build Tools the component IDs differ).
|
||||
$msbuild = & $vswhere -latest -products '*' `
|
||||
-requires Microsoft.Component.MSBuild `
|
||||
-find "MSBuild\**\Bin\MSBuild.exe" | Select-Object -First 1
|
||||
if (-not $msbuild) { throw "MSBuild not found via vswhere" }
|
||||
if (-not $msbuild) {
|
||||
Write-Host "Targeted lookup failed; trying broader search."
|
||||
$msbuild = & $vswhere -latest -products '*' -prerelease `
|
||||
-find "MSBuild\**\Bin\MSBuild.exe" | Select-Object -First 1
|
||||
}
|
||||
if (-not $msbuild) {
|
||||
# Last resort: any MSBuild.exe under any VS install path.
|
||||
$vsRoots = & $vswhere -all -prerelease -products '*' -property installationPath
|
||||
foreach ($r in $vsRoots) {
|
||||
$candidate = Get-ChildItem -Path $r -Recurse -Filter 'MSBuild.exe' -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.FullName -like '*\Bin\MSBuild.exe' -and $_.FullName -notlike '*\amd64\*' } |
|
||||
Select-Object -First 1
|
||||
if ($candidate) { $msbuild = $candidate.FullName; break }
|
||||
}
|
||||
}
|
||||
if (-not $msbuild) { throw "MSBuild not found via vswhere or filesystem search" }
|
||||
Write-Host "msbuild: $msbuild"
|
||||
|
||||
# Two-stage restore covers both project flavors in this solution:
|
||||
# - CustomActions.vcxproj uses old-style packages.config -> nuget restore
|
||||
|
||||
Reference in New Issue
Block a user