Skip to content

Commit 9e42b72

Browse files
Ben HillisCopilot
andcommitted
setup-dev-env: prefer VS 2022, warn on VS 2026 fallback
Mirror CMakeLists.txt logic: query vswhere with [17.0,18.0) first for VS 2022, fall back to [18.0,19.0) for VS 2026 with a warning that clang-format output may differ from pipeline expectations. Component checks now run against the correct VS installation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 16079e2 commit 9e42b72

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

tools/setup-dev-env.ps1

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,43 @@ if ($cmake)
6161
Check "CMake >= 3.25$(if ($cmakeVersion) { " (found $cmakeVersion)" })" $cmakeOk "winget install Kitware.CMake"
6262

6363
# --- Visual Studio ---
64+
# Mirror CMakeLists.txt: prefer VS2022 [17.0,18.0) to keep clang-format
65+
# aligned with pipeline expectations. Fall back to VS2026 [18.0,19.0) with a warning.
6466
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
6567
$vsInstall = $null
6668
$vsVersion = $null
6769
$vsOk = $false
70+
$vsWarning = $null
6871
if (Test-Path $vswhere)
6972
{
70-
$vsInstall = (& $vswhere -latest -property installationPath 2>$null | Select-Object -First 1)
71-
$vsVersionText = (& $vswhere -latest -property installationVersion 2>$null | Select-Object -First 1)
73+
# Try VS2022 first
74+
$vsInstall = (& $vswhere -version "[17.0,18.0)" -products * -latest -property installationPath -prerelease 2>$null | Select-Object -First 1)
75+
$vsVersionText = (& $vswhere -version "[17.0,18.0)" -products * -latest -property installationVersion -prerelease 2>$null | Select-Object -First 1)
76+
77+
if (-not $vsInstall)
78+
{
79+
# Fall back to VS2026
80+
$vsInstall = (& $vswhere -version "[18.0,19.0)" -products * -latest -property installationPath -prerelease 2>$null | Select-Object -First 1)
81+
$vsVersionText = (& $vswhere -version "[18.0,19.0)" -products * -latest -property installationVersion -prerelease 2>$null | Select-Object -First 1)
82+
if ($vsInstall) { $vsWarning = "VS 2022 not found; using VS 2026. clang-format output may differ from pipeline expectations." }
83+
}
84+
7285
if ($vsInstall) { $vsInstall = $vsInstall.Trim() }
7386
if ($vsVersionText)
7487
{
7588
try
7689
{
7790
$vsVersion = [version]$vsVersionText.Trim()
78-
$vsOk = (-not [string]::IsNullOrWhiteSpace($vsInstall)) -and ($vsVersion.Major -ge 17)
91+
$vsOk = -not [string]::IsNullOrWhiteSpace($vsInstall)
7992
}
8093
catch {}
8194
}
8295
}
8396
Check "Visual Studio 2022+$(if ($vsVersion) { " (found $vsVersion)" })" $vsOk $script:VsInstallFix
97+
if ($vsWarning)
98+
{
99+
Write-Host " WARNING: $vsWarning" -ForegroundColor DarkYellow
100+
}
84101

85102
# --- VS Components (only check if VS 2022+ is found) ---
86103
if ($vsOk)

0 commit comments

Comments
 (0)