build: select a VS instance with the x64 C++ toolset among all installs #485
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!485
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/485/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@FZNull on GitHub · 2026-11-22 06:47 UTC · original
FZNull:build/dev-ps1-vswhere-all-instances→main· +17 −1 · 1 files · 1 commits · merged 2026-11-22 07:10 UTCChange
tools/dev.ps1picks a Visual Studio installation withvswhere -latest -requiresfor both the x64 C++ toolset and the CMake component. A machine that installs CMake and Ninja from a package manager but has no VS CMake component fails that query even though a usable toolset instance exists, and the script throws the install error.This change adds a fallback for that case: when no instance satisfies the combined requirement, query again for the x64 C++ toolset alone and pick the newest instance that actually ships
Common7\Tools\Launch-VsDevShell.ps1. The primary query keeps-latest -products '*' -requiresunchanged.Reproduction
Environment: Visual Studio Community 2026 (18.9, no C++ workload) and Visual Studio Build Tools 2026 (18.4, MSVC 14.50.35717, no CMake component), CMake 4.5.1 and Ninja 1.13.2 from scoop, Windows SDK 10.0.26100.0, DXC 1.9.2609.5, Python 3.13.12, Windows 11 build 26300.9974.
On this two-install setup:
-latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.VC.CMake.Project-latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64-all-all -sort -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64C:\Program Files (x86)\Microsoft Visual Studio\18\BuildToolsBecause the toolset-only
-latestquery returns nothing here, the fallback lists incomplete instances with-all -sortand then verifies thatCommon7\Tools\Launch-VsDevShell.ps1exists, so an incomplete installation without a usable environment is never handed to the caller.Before the change,
.\tools\dev.ps1threw the install error above even though the toolchain was present.With the change,
.\tools\dev.ps1opens the Build Tools developer shell and configure, build and test succeed:Notes
-latestquery selects it exactly as before and the fallback never runs.AI-assisted.
@R0Y00 on GitHub · 2026-11-22 06:57 UTC · original
The fallback for an external CMake/Ninja installation addresses the reported setup. The local
vswhere -?confirms-allalso includes incomplete installations, so selecting the first result can handLaunch-VsDevShell.ps1an unusable instance. Please keep-latest -products '*' -requireson both queries, and change only the required components in the fallback. On your two-install setup, please confirm the combined query returns nothing and the VC-only query returns the Build Tools path. That isolates the fix and preserves the original launchable-instance filter.@FZNull on GitHub · 2026-11-22 07:06 UTC · original
Thanks — here are the exact results on the two-install setup (Visual Studio Community 2026 18.9 without the C++ workload, and Visual Studio Build Tools 2026 18.4 with MSVC 14.50.35717 but no CMake component):
So on this setup a
-latesttoolset-only query cannot return the Build Tools path. The branch therefore keeps the primary query exactly as before (-latest -products '*' -requireswith both components) and changes the fallback to a toolset-only-all -sortquery, followed by a check thatCommon7\Tools\Launch-VsDevShell.ps1exists before the instance is selected. That keeps the fallback from handing an unusable incomplete installation to the launcher while still finding the usable one here.With the pushed commit
dc406e4,.\tools\dev.ps1opens the Build Tools developer shell (VSINSTALLDIR points at the Build Tools instance,cl/cmake/ninjaresolve) and the configure/build/test results in the PR body are unchanged. The PR description now records the query table above.If you would rather the fallback stay
-latestonly, I can keep it and instead skip the fallback on this setup — but then the script still refuses a machine with a working toolset, which is what this PR set out to fix. Happy to adjust either way.