From b9faf80f86a253ae5b9c77dafe341e43227397c1 Mon Sep 17 00:00:00 2001 From: kitbyte Date: Mon, 15 Jun 2026 00:54:21 +0300 Subject: [PATCH] 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. --- CHANGELOG.md | 2 +- build.ps1 | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 597a4c1..7c9ddb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build.ps1 b/build.ps1 index db2a5c1..51c6d4f 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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