Repository navigation
fix: "Invalid version" for MSBuild 18.0 and pre-v12 versions - #14
Merged
Merged
Conversation
Co-authored-by: jmkcoder <149906506+jmkcoder@users.noreply.github.com> Agent-Logs-Url: https://github.com/jmkcoder/gulp-msbuild/sessions/9c8ee201-5404-440a-8d0c-79cdaf5c2aa6
- Pre-v12 versions (1.0-4.0) no longer require vswhere.exe; they are found directly in the .NET Framework directory - V16+ version detection now matches installations by the major number in `installationVersion` (from vswhere JSON), replacing the fragile path-substring check that failed when VS 18's folder name doesn't contain '18' - Add 7 new tests covering pre-v12 handling, v18/v16/v17 by installationVersion, and auto-detection of VS 18 Co-authored-by: jmkcoder <149906506+jmkcoder@users.noreply.github.com> Agent-Logs-Url: https://github.com/jmkcoder/gulp-msbuild/sessions/9c8ee201-5404-440a-8d0c-79cdaf5c2aa6
Copilot
AI
changed the title
[WIP] Fix invalid toolsVersion issue with MSBuild 18.0
Fix "Invalid version" for MSBuild 18.0 and pre-v12 versions
Mar 21, 2026
jmkcoder
marked this pull request as ready for review
March 21, 2026 19:17
jmkcoder
approved these changes
Mar 21, 2026
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.
findVersion()threwInvalid versionfor anytoolsVersiondue to two independent bugs inmsbuild-finder.ts.Bugs fixed
Pre-v12 versions incorrectly required vswhere.exe
Versions 1.0–4.0 live under
C:\Windows\Microsoft.Net\Framework[64]\— vswhere has no knowledge of them. The old code always called vswhere first; without it,findVersion()returnednull.Fix: Short-circuit for
parsedNumber < 12— callconcatPreV12()and check the path directly, no vswhere involved.V16+ detection used fragile path-substring matching
concatV16AndAbovecheckedinstallationPath.includes(MSBUILD_VERSIONS[version]). Works for v16/v17 because VS puts the year (2019,2022) in the folder. For v18 the mapped value is'18'— any VS whose install folder doesn't contain the literal string'18'(e.g., a futureVisual Studio 2026) silently returns'', producingnull→Invalid version.Fix: For major ≥ 16, find the matching installation using
installationVersionfrom the vswhere JSON instead of path substring matching:This correctly resolves any present or future VS major version regardless of its folder naming convention.
concatV16AndAboveandMSBUILD_VERSIONSare left intact as utility helpers.Original prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.