From 5aeceb09f18b0b16cb47088954a1b55f3b3a087c Mon Sep 17 00:00:00 2001 From: Jeff Noel Date: Sun, 16 Aug 2026 22:51:02 -0400 Subject: [PATCH 1/3] vs-shell: pass -products * to vswhere so Build Tools installs are found vswhere skips Build Tools products by default, so on a machine whose newest toolset is a Build Tools install the script silently picks an older IDE install (here: 2022 Community 17.7, whose STL predates __std_minmax_8i -> JavaScriptCore.lib link failure) or falls through to the hardcoded 2022 paths. --- scripts/vs-shell.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/vs-shell.ps1 b/scripts/vs-shell.ps1 index ffbf5eecaa40..e8508b37394a 100755 --- a/scripts/vs-shell.ps1 +++ b/scripts/vs-shell.ps1 @@ -15,7 +15,10 @@ if($env:VSINSTALLDIR -eq $null) { throw "Command not found: vswhere (did you install Visual Studio?)" } - $vsDir = (& $vswhere -prerelease -latest -property installationPath) + # -products * is required to also match Build Tools installs, which vswhere + # skips by default (a machine with only Build Tools would fall through to the + # hardcoded 2022 paths and miss newer toolsets entirely). + $vsDir = (& $vswhere -products * -prerelease -latest -property installationPath) if ($vsDir -eq $null) { # Check common VS installation paths $searchPaths = @( From e1f92920d7848a51c748cc3821384ce19519bc2c Mon Sep 17 00:00:00 2001 From: Jeff Noel Date: Sun, 16 Aug 2026 22:59:50 -0400 Subject: [PATCH 2/3] Require the target-arch C++ toolset in the vswhere query Review follow-up: -products * alone could select an install without the C++ tools; -requires VC.Tools.{x86.x64,ARM64} guards that. --- scripts/vs-shell.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/vs-shell.ps1 b/scripts/vs-shell.ps1 index e8508b37394a..03da2056e8bf 100755 --- a/scripts/vs-shell.ps1 +++ b/scripts/vs-shell.ps1 @@ -17,8 +17,10 @@ if($env:VSINSTALLDIR -eq $null) { # -products * is required to also match Build Tools installs, which vswhere # skips by default (a machine with only Build Tools would fall through to the - # hardcoded 2022 paths and miss newer toolsets entirely). - $vsDir = (& $vswhere -products * -prerelease -latest -property installationPath) + # hardcoded 2022 paths and miss newer toolsets entirely). Require the C++ + # toolset for the target arch so an install without it can't be selected. + $vcTools = if ($script:IsARM64) { "Microsoft.VisualStudio.Component.VC.Tools.ARM64" } else { "Microsoft.VisualStudio.Component.VC.Tools.x86.x64" } + $vsDir = (& $vswhere -products * -requires $vcTools -prerelease -latest -property installationPath) if ($vsDir -eq $null) { # Check common VS installation paths $searchPaths = @( From 4ecb058b2c778a5785c5ac7185af1908f8067a0a Mon Sep 17 00:00:00 2001 From: Jeff Noel Date: Sun, 16 Aug 2026 23:06:31 -0400 Subject: [PATCH 3/3] Validate the C++ toolset in the hardcoded-path fallback too Review follow-up: the fallback took the first 2022 subdirectory unvalidated; it now only accepts one shipping VC\Tools\MSVC and still throws clearly when none match. --- scripts/vs-shell.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/vs-shell.ps1 b/scripts/vs-shell.ps1 index 03da2056e8bf..167364515ab5 100755 --- a/scripts/vs-shell.ps1 +++ b/scripts/vs-shell.ps1 @@ -29,7 +29,11 @@ if($env:VSINSTALLDIR -eq $null) { ) foreach ($searchPath in $searchPaths) { if (Test-Path $searchPath) { - $vsDir = (Get-ChildItem -Path $searchPath -Directory | Select-Object -First 1).FullName + # Only accept an install that actually ships the C++ toolset (vswhere + # isn't usable here, so check for the toolset directory instead). + $vsDir = (Get-ChildItem -Path $searchPath -Directory | + Where-Object { Test-Path (Join-Path $_.FullName "VC\Tools\MSVC") } | + Select-Object -First 1).FullName if ($vsDir -ne $null) { break } } }