-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect VS2017 #1103
Detect VS2017 #1103
Conversation
(changed COM tool from an exe to a |
Node-gyp must support Windows 7/2008R2 while Node does, and those versions of Windows ship with PowerShell 2.0. The module you use here seems to require at least version 3. We could ask users to update PowerShell, but there have been issues in the past from users locked in corporate environments with no permissions to install anything, so this might be troublesome to most and impossible to some. Using an executable opens an issue of trust in the committed file. We could get around this by setting up a job in node's release infrastructure to compile and sign an executable to use here, but only if must be. @refack what issue do you see with |
I'll check if I can back port the script...
|
@refack I just checked this on Windows 7 - after installing VS2017 and selecting Desktop Development with C++, powershell is still at version 2 |
Yep just did that too 😣 (also encountered the |
P.S. same config (VS2017 build tools on Windows 7SP1):
Apparently the COM interface doesn't get registered |
Unless you install the .NET 4.6 SDK |
@refack any luck with PowerShell v2? |
@joaocgreis just cracked it (and added an undocumented Registry approach as backup) |
I've tested, and I could not get this to work because of spaces in the path. Also, the registry key approach does not provide the SDK. @heaths this looks for the path in the registry at |
Paths could always have spaces. Make sure the path is quoted and you shouldn't have a problem. No registry values are supported for VS2017. Whatever you found is probably just a left-over that should've been removed. MSIs are singletons and may have nothing to do with where VS instances are installed. |
919a9b2
to
2973558
Compare
Fixed path escaping issue, and now the code works with Powershell "core". P.S. I refactored my code into a package (it's has no dependecies of it's own) what might be the push back of adding it as a dependency? |
a9cabb9
to
0376bd6
Compare
As my detection package is getting traction, and bug fixes, I believe it's worth the add. @bnoordhuis @kunalspathak I think now it's mature enough to cc you :) |
While I appreciate the community working together to fill gaps - being a long-time open source contributor myself - I'm curious how using the batch scripts are easier than acquiring the PowerShell module: install-module vssetup -scope currentuser # only needed once
$installationPath = get-vssetupinstance | select-vssetupinstance -latest | select-object -expand InstallationPath I will be keeping these up to date with new functionality as we bring it online. |
First, I agree with Heath: The PowerShell solution is probably best for most users. I had a discussion with the Boost folks that lays out the options. This thread may be interesting to you: boostorg/build#157 |
@heaths It's a change to the underlying system. While reasonable for developers, |
@refack FWIW, I'm working to finish up a single native binary that can return information in a number of formats. A prototype actually ships in the tools subdirectory of the Microsoft.VisualStudio.Setup.Configuration.Native NuGet package, which is what several VC projects are using. You might take a look at that, as the eventual new project will also grow over time. These are also fully supported. |
@heaths That's sounds promising. Maybe also also consider implementing |
@heaths Where's the best place to leave feedback on "Microsoft.VisualStudio.Setup.Configuration.Native"? I have one request; we need the version number for installed SDKs so we could populate the |
P.S. IMHO |
@refack, given that NuGet and node.js were designed around the same time, that's not a surprise. They both reflect how the world was thinking about packages at the time. Given node.js is a year earlier, there might be inspiration, but I'm not the one to comment on that. |
@refack re: PowerShell, people should just use the VSSetup module. Even with We can consider adding re: feedback, consider it heard. We can consider how to do that, but the data on which the query API works doesn't store that. The more data we store, we slow the query API down. That's only one type of question to ask, but I'm sure other people have others. We can't really store every conceivable answer. Instead, it would be better that the Windows SDK - which is actually a system singleton (i.e. it's still MSI-based and will be for the foreseeable future since it's so big and used by things outside VS) - write something like that. I will pass along feedback. For now, you could do something like the following as long as their package ID pattern holds: get-vssetupinstance | select -expand Packages | where Id -match 'Win10SDK_\d' | select Version |
@heaths Thanks again for listening. (as for figuring out the SDK that's almost exaclty what I'm doing in my CS script) |
@heaths we must support Windows 7 and 2008R2 as shipped, with Powershell v2. I did not manage to get the VSSetup module to work with it, is there a way? I'm not thrilled about landing a binary either - even if we can trust the binary's content we might run into issues with antivirus software because node-gyp must be usable as downloaded from the internet (e.g. after updating npm). Currently, the solution here, using the COM API, seems to be the best one. @refack can you move the gyp bump to a different PR, or is it required for this? Also, the commit with the Gyp floating patch that you had before looked good, can you bring it back (or is there a reason not to)? About using a package: @refack can you commit to always supporting the same versions of Windows that node does? @nodejs/node-gyp are there other reasons why we might not want this as a package? |
I can do the minimal patch, give me a few minutes |
af270f9
to
322f30b
Compare
322f30b
to
3b214de
Compare
I have published a release of vswhere - a single-file, native executable you can redistribute - at https://github.com/Microsoft/vswhere. It currently emits data in plan text and JSON and would be fairly easy to use. For example, to find the root path to the latest version installed for native tools: for /r "usebackq tokens=1* delims=: " %%i in (`vswhere.exe -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop`) do (
if /i "%%i"=="installationPath" set dir=%%j
)
rem %dir% now contains the root installation path, if available |
3b214de
to
b25b8eb
Compare
I tweaked the |
Reviewed and opened #1130 with a slightly modified version. |
b25b8eb
to
33be066
Compare
I brough back |
@bnoordhuis @joaocgreis |
Getting better coverage from AppVeyor VS2015 and vs2017 pass |
Great news we landed VS2017 support to |
The officially supported vswhere tool is now available as part of the install starting today with Visual Studio 15.2 preview 2: https://blogs.msdn.microsoft.com/heaths/2017/04/21/vswhere-is-now-installed-with-visual-studio-2017/. This doesn't fix all the existing installs of VS 2017 but going forward you can now detect the VS install locations and whether C++ tools are available from a scripted environment. |
@AndrewPardoe Are you following my list from https://developercommunity.visualstudio.com/content/problem/35325/missing-vs150comntools.html? |
@refack I wasn't, but I'm searching for all the places online where vswhere was mentioned and trying to link to this post : ) Thank you for the list! |
Patch Set 4: Sorry, but this is not the way to do that. Registry key approach was discussed downstream in nodejs, Heath Stewart who is responsible for the VS installer said explicitly that the registry entry is not supported (nodejs/node-gyp#1103 (comment)) In node-gyp we used Rafael's powershell script that can query VS COM server (nodejs/node-gyp#1130). We used that to find VS and set environment variables. IMHO we should do the same thing here. Patch-set: 4
Patch Set 4: > Patch Set 4: > > Sorry, but this is not the way to do that. Registry key approach was discussed downstream in nodejs, Heath Stewart who is responsible for the VS installer said explicitly that the registry entry is not supported (nodejs/node-gyp#1103 (comment)) > > In node-gyp we used Rafael's powershell script that can query VS COM server (nodejs/node-gyp#1130). We used that to find VS and set environment variables. IMHO we should do the same thing here. We could also assume the default install location and allow users to set an environment variable if they have a non-default install. That is what Chrome is doing - the complexity of the COM solution didn't seem justified, at least initially. Patch-set: 4 Reviewer: Gerrit User 1128439 <1128439@3ce6091f-6c88-37e8-8c75-72f92ae8dfba>
Patch Set 4: > Patch Set 4: > > Sorry, but this is not the way to do that. Registry key approach was discussed downstream in nodejs, Heath Stewart who is responsible for the VS installer said explicitly that the registry entry is not supported (nodejs/node-gyp#1103 (comment)) > > In node-gyp we used Rafael's powershell script that can query VS COM server (nodejs/node-gyp#1130). We used that to find VS and set environment variables. IMHO we should do the same thing here. Obviously, but I like this solution for this project, it's good enough... ... ... ... ... ... ... You know what, I'll make another PR with the full script Patch-set: 4 Reviewer: Gerrit User 1188132 <1188132@3ce6091f-6c88-37e8-8c75-72f92ae8dfba>
Based on @bzoz's #1101 but without python `comtypes'
Also bumped
gyp
to latest version and updated out patch files