Fix razzle.cmd MSBuild detection silently failing on VS 2026 (18.x) - #20474
Fix razzle.cmd MSBuild detection silently failing on VS 2026 (18.x)#20474Dinah Xiaoman G (DinahK-2SO) wants to merge 1 commit into
Conversation
|
Hello Leonard Hecker (@lhecker) and Dustin L. Howett (@DHowett) , please take a loook at this update. |
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
Before we consider this, can you explain to me how you validated your prior pull request to this file before submitting it to us if it was so critically broken?
|
What I mean, btw, is that... I saw that you mentioned you ran it from a developer command prompt session, but you were changing code that was practically unreachable in that session. How can we be sure that it works this time? |
|
And, why should we not just delete these helpers (/cc Mike Griese (@zadjii-msft))? |
|
Hi Dustin L. Howett (@DHowett) ,
This is my mistake. I am sorry. 😢 I should have explicitly tested the final version from a regular cmd.exe with MSBuild absent from
For this revision, I tested in these scenarios:
I included the results in the PR description. I apologize for the additional investigation and review work it caused. |
Summary
razzle.cmdcould reportCould not find MSBuilddespite a valid Visual Studio installation, unless MSBuild was already available inPATH.Root Cause
MSBuild discovery used this command:
for /fexecutes the command between backticks through a nestedcmd.exe /c. Because the command begins with a quoted executable path and also contains the quoted version range, the special quote-handling rules ofcmd.exe /ccause the command to be parsed incorrectly.Consequently, the
)in"[17.0,19.0)"is interpreted as command syntax instead of part of the version argument. Thevswherecommand fails and leavesMSBUILDunset.How This Slipped Through Testing
During development of the previous change, an intermediate version was tested in a regular cmd:
It worked because
%VSWHERE%was not quoted, where there's only one pair of"andcmd.execan parse it as expected.I later added quotes around
%VSWHERE%to support paths containing spaces, which caused the regression, but I did not retest the exact final command through the affected MSBuild discovery path.Most of my local usage ran
razzle.cmdfrom a Visual Studio Developer Command Prompt. Because MSBuild was already inPATH, the script was always successful and the affected discovery step was skipped.Fix
The updated script runs
vswheredirectly and redirects its output to a temporary file. It then reads that file withfor /f.This removes the nested
cmd.exe /cquoting ambiguity while continuing to support paths containing spaces or parentheses.This issue was originally found and fixed in microsoft/intelligent-terminal#497; applying the same fix here.
References and Relevant Issues
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed
Verified this PR on below 3 scenarios:
in a brand new environment with no Visual Studio or msbuild installed.

It throws the expected error:
Could not find vswhere on your machine ...in an environment with Visual Studio installed but not added into PATH.

It finds the msbuild and set its variable as expected.
in Visual Studio's Developer Command Prompt, where msbuild's already in PATH:

It sets the msbuild variable as expected.
PR Checklist