fix(build): resolve Visual Studio version-agnostically

The runner's windows-latest image bumped Visual Studio past 2022, so the
hardcoded vswhere range [17.0,18.0) and the 'Visual Studio 17 2022' CMake
generator no longer matched, failing the release build. Pick the latest
installed VS and derive the generator from its version/product line.
This commit is contained in:
kitbyte
2026-06-15 00:54:21 +03:00
parent 6395ca3a27
commit b9faf80f86
2 changed files with 23 additions and 8 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ The newest entry must match the version in `WandEnhancer/Properties/AssemblyInfo
### Features
- The Remote Web Panel now shows mod names, descriptions, and instructions translated to your WeMod account language. #98
- The Remote Web Panel now shows mod names, descriptions, and instructions translated to your WeMod account language by @YifePlayte in #98. Related issue: #85
- Added a language selector to the Remote Web Panel (English, Russian, German, French, Spanish, Simplified Chinese) with automatic detection from the browser language.
### Improvements
+22 -7
View File
@@ -43,15 +43,21 @@ function Resolve-NuGetPath {
return $nugetPath
}
function Resolve-MSBuildPath {
function Resolve-VisualStudio {
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
if (-not (Test-Path $vswhere)) {
throw "vswhere.exe not found: $vswhere"
}
$installationPath = & $vswhere -latest -version '[17.0,18.0)' -requires Microsoft.Component.MSBuild -property installationPath
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($installationPath)) {
throw 'Visual Studio 2022 with MSBuild was not found.'
# No version pin: pick whatever VS the host has (2022/2026/newer) so CI
# keeps working when the runner image bumps its Visual Studio major.
$vsArgs = @('-latest', '-prerelease', '-products', '*', '-requires', 'Microsoft.Component.MSBuild')
$installationPath = & $vswhere @vsArgs -property installationPath
$installationVersion = & $vswhere @vsArgs -property installationVersion
$productLine = & $vswhere @vsArgs -property catalog_productLineVersion
if ([string]::IsNullOrWhiteSpace($installationPath)) {
throw 'Visual Studio with MSBuild was not found.'
}
$msbuildPath = Join-Path $installationPath 'MSBuild\Current\Bin\MSBuild.exe'
@@ -59,7 +65,15 @@ function Resolve-MSBuildPath {
throw "MSBuild.exe not found: $msbuildPath"
}
return $msbuildPath
$major = ($installationVersion -split '\.')[0]
if ([string]::IsNullOrWhiteSpace($major) -or [string]::IsNullOrWhiteSpace($productLine)) {
throw "Could not determine the Visual Studio version (version='$installationVersion', line='$productLine')."
}
return [pscustomobject]@{
MSBuild = $msbuildPath
Generator = "Visual Studio $major $productLine"
}
}
function Invoke-Step {
@@ -78,8 +92,9 @@ function Invoke-Step {
$cmake = Resolve-CommandPath 'cmake'
$nuget = Resolve-NuGetPath
$pnpm = Resolve-CommandPath 'pnpm'
$msbuild = Resolve-MSBuildPath
$generator = 'Visual Studio 17 2022'
$vs = Resolve-VisualStudio
$msbuild = $vs.MSBuild
$generator = $vs.Generator
Invoke-Step 'Install web-panel dependencies' {
& $pnpm --dir $webPanelDir install --frozen-lockfile