Support Visual Studio 2017 and 2019 #2
Merged
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.
Description of the Change
Main change:
Related changes:
--msvs_versionnode-gyp flag, which sets a specific version of Visual Studio that node-gyp must find, or else it will error out.Explanation (click to expand):
Builds on
apm's existing code to detect installs of Visual Studio, by adding the ability to detect Visual Studio 2017 and 2019.Those versions of Visual Studio are now fully supported in the version of node-gyp we use (node-gyp@5).
As of node-gyp PR nodejs/node-gyp#1762, node-gyp is much better than us at finding Visual Studio installs and identifying whether on not they can be used. This isn't a simple matter of having Visual Studio or not, but also various components must be installed.
Given that our detection is worse, I have made it so
apmno-longer sets the--msvs_versionflag. This flag forces node-gyp to use the specified major version of Visual Studio/Build Tools. It can only restrict node-gyp within usable installs. There is no scenario where setting this causes any benefit to us. But if we get it wrong (and our detection is worse, so we very likely would), this can cause node-gyp to refuse to use a valid Visual Studio/Build Tools install and error out.Alternate Designs
This, but with some of the changes reverted/taken out.
Details
All commits in this PR are designed to be logical choices that are well-backed-up by the explanation and reasoning given.
That said, the commits are in order of how radical the change is, or how controversial I thought the change might be. If any of the commits/changes are objectionable, please let me know, and the rest of the PR still makes sense without that change. This is a few related changes bundled together, but any of the three bullet points is a positive step in the right direction, and works independent of the other two bullet points.
Benefits
Possible Drawbacks
None that I am aware of. Before this PR, we have been artificially limiting how good a job node-gyp could do to find Visual Studio, in certain cases. Now, with this PR, we stop doing that.
Reaching for a hypothetical problem: I suppose if Visual Studio 2017 or 2019 are buggy, this exposes our users to that. (In my experience, VS 2017 and 2019 are not buggy.)
Verification Process
Lengthy "Verification Process" section contents (click to expand):
This un-blocks
apmfrom using a correctly-detected, working install of Visual Studio 2019 in (forked) Atom's CI.Breakdown of the "Before" case: The issue in this case was that
apmdetected an install of 2015 that turned out to be unusable. The error is: "could not find MSBuild in registry for this version". At the bottom of the error message, a message points out that 2019 would have been a valid version, had we allowed node-gyp to use it:Furthermore,
apm --versioncan now find Visual Studio 2017 and 2019.Before and after on the same machine, with Visual Studio 2019 Community installed:
Before:
After:
Note that Visual Studio 2019 is detected:
visual studio 2019(on the bottom line of output fromapm --version).Here's the before and after on another machine, this time with Visual Studio 2017:
Before
After
Note that Visual Studio 2017 is detected:
visual studio 2017(on the bottom line of output fromapm --version).Applicable Issues
Upstream PR: atom#892
Fixes atom#893