fix(release): make MSBuild discovery resilient to newer VS lines#29
Open
cmxl wants to merge 1 commit into
Open
fix(release): make MSBuild discovery resilient to newer VS lines#29cmxl wants to merge 1 commit into
cmxl wants to merge 1 commit into
Conversation
release.ps1 relied on vswhere.exe to locate MSBuild, but the vswhere
bundled with the VS Installer can pre-date newer VS lines (e.g. Dev18 /
VS 2026) and return nothing for them. When that happens, $msBuildPath is
null and Get-Command $msBuildPath raises:
Cannot validate argument on parameter 'Name'.
The argument is null or empty.
Replace the single vswhere call with a Find-MSBuildPath function that:
- Tries vswhere first (existing behavior preserved).
- Falls back to scanning known install paths under
"Microsoft Visual Studio\<ver>\<edition>\MSBuild\Current\Bin\MSBuild.exe"
for VS 17 / 18 / 2022 / 2026 across BuildTools / Community /
Professional / Enterprise editions.
- Throws a clear error if neither approach finds MSBuild.
Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
release.ps1fails on the discovery step with:The script relies on
vswhere.exeto locate MSBuild. On machines where the bundledvswheredoesn't recognise the installed Visual Studio line, vswhere returns no output,$msBuildPathends up null, and the next line —Get-Command $msBuildPath— raises the validation error above before anything else runs.Environment that triggered this
I only installed Visual Studio Build Tools 2026 (and the .NET SDKs — note that the .NET SDKs do not ship an MSBuild compatible with the ClickOnce publish flow this script uses, so the .NET SDK MSBuild can't substitute for full MSBuild here).
Build Tools 2026 installs MSBuild at:
…and that binary works fine (
msbuild -version→ 18.6.3). The problem is purely discovery: thevswhere.exeshipped with the current VS Installer (v3.1.7, from 2023) predates VS 2026 (Dev18) and returns no output for it, so the script never finds the path.Changes
release.ps1— replaced the inlinevswhereinvocation with aFind-MSBuildPathfunction that:vswherefirst (existing behaviour preserved on machines where it works).Microsoft Visual Studio\<ver>\<edition>\MSBuild\Current\Bin\MSBuild.exefor VS
17/18/2022/2026acrossBuildTools/Community/Professional/Enterprise.Testing
Find-MSBuildPathreturns the Build Tools 2026 MSBuild on a machine wherevswherereturns nothing.msbuild -version→18.6.3+84d3e95b4 for .NET Framework).vswheredoes work — vswhere is still tried first and its result is used as-is.