Repository navigation
Description
How about to provide this (or similar) tool by default with VS as front-controller (into one known unified place) for simple requests about simple informations like searching of available msbuild tools and other informations about all installed VS instances ?
It's important for any small tools like this, that contains all logic via single batch file etc.
I mean just look the gnt.bat (full logic for work with nuget packages: creating new, installing, etc. via msbuild) and tell me, how we should now ? +vswhere.exe ?
For any searching of msbuild tools it looked like this msbuild-helper before (to build in any places like CI build-servers, any custom user's env etc. - easy and works well)
this:
for /f "usebackq tokens=1* delims=: " %%i in (`vswhere -latest -requires Microsoft.Component.MSBuild`) do (
if /i "%%i"=="installationPath" set InstallDir=%%j
)
...is much more useful when your vswhere (or something else) will be provided initially as a simple console tool and located in already known place (to aggregate any requests as front-controller as I said above).
This is possible by MS ? or how it should be now for something like above ?
Update 1
Final solutions to find msbuild.exe from VS2017:
Via batch scripts ( no powershell, no dotnet cli )
For online machines, now appeared this - https://github.com/3F/hMSBuild
A single compiled batch file ~19 Kb that can be embedded inside any scripts or other batch files:
Usage is same as it would be same for msbuild.
Usage: hMSBuild [args to hMSBuild] [args to msbuild.exe or GetNuTool core]
------
Arguments:
----------
-no-vs - Disable searching from Visual Studio.
-no-netfx - Disable searching from .NET Framework.
-no-vswhere - Do not search via vswhere.
-vsw-version {arg} - Specific version of vswhere. Where {arg}:
* 2.6.7 ...
* Keywords:
`latest` - To get latest remote version;
`local` - To use only local versions;
(.bat;.exe /or from +15.2.26418.1 VS-build)
...
Solution by Microsoft
here:
After further discussion internally, we're going to add vswhere.exe to a known location (such as %CommonProgramFiles%) in an upcoming servicing release, which will address the original issue as proposed by Denis Kuzmin (@3F) at the top of the thread. This will give you the flexibility to use ...
Update 2
here by Heath Stewart (@heaths):
vswhere is now available as part of the install starting today with Visual Studio 15.2 preview 2:
Update 3
Just removed direct links to hMSBuild 1.x ( 2017, which are still actively referenced ). Please use latest versions:
🧱 Compiled text-based embeddable pure batch-scripts for searching of available MSBuild tools.
- https://github.com/3F/hMSBuild ( .bat ~19 KB, no powershell, no dotnet cli )
Activity
heaths commentedon Mar 14, 2017
We are considering this, but even if we did in a subsequent update, VS2017 RTW already shipped. vswhere was meant to be redistributed as needed, so I the meantime and for VS2017 RTW support you could consider adding the file to the repo.
3F commentedon Mar 14, 2017
Yes, I noticed -_- ... and I don't know how to easily solve this problem instead of adding vswhere for a lot of public repos.
Moreover, as you can see this can be a simple small script-tool for end-users. So I don't know what to do at all for this cases (well, I know but...), because now it requires ... omg.
As I see, gnt.bat tool above should correctly work via tool from .NET Framework, thus nuget-packages are still not problem and we can distribute vswhere automatically (like for other my X tool for additional complex build-scripting that wrapped by single bat file and distributed via nuget server), however: the nuget package will not useful for offline machines :(, so the easy way, yes, to distribute 'as is' together with repo. That's of course amazing for simply finding path to the msbuild tools <_<
Need to think -_-
Good ! I hope to see something from next patch-releases at least.
Thanks,
KindDragon commentedon Mar 17, 2017
You can try to install it from Chocolatey, It will be automatically added to
PATH3F commentedon Mar 17, 2017
the problem not for path to vswhere because we can still use gnt like:
but thanks, it's first time when I hear about chocolatey :)
grafikrobot commentedon Mar 28, 2017
The Boost C++ Libraries project lobbied for this to be included before the release went out. But those requests failed. Most likely the VS release manager didn't consider this a high-priority issue. But now we have a situation where many different projects like Boost, Cmake, etc will end up including a patchwork of incompatible detection methods in their repos.
For Boost including the executable of this utility might be an option.. If it where not for the license. As, if you can believe, the Boost license is less restrictive than the MIT license in use for vswhere. My suggestion would be to relicense vswhere to the "Public Domain" or the "Boost License", or some other license that doesn't require license terms for binary inclusion.
heaths commentedon Mar 28, 2017
René Ferdinand Rivera Morell (@grafikrobot) looking at the boostorg/boost repo I see a number of bootstrap scripts that pull down files (granted, Python scripts). Perhaps the MIT license is more restrictive but you merely need to pull it. You don't even have to include it in your repo. That's why the vswhere.exe executable itself (not ZIP'd or anything) is available here on GitHub. How is pulling that different from pulling other build-required scripts?
grafikrobot commentedon Mar 28, 2017
Heath Stewart (@heaths) I'm not sure where you see the bootstrap pulling anything. As it's designed to operate entirely offline. For example it's possible to download a Boost release unplug your network cable (or equivalent) and then do a complete build. Which is actually required for some platforms like some mainframes and other specialized hardware that are not internet connected.
heaths commentedon Mar 28, 2017
René Ferdinand Rivera Morell (@grafikrobot) what is this? https://github.com/boostorg/boost/blob/master/bootstrap.bat
Even if we did install it with our installer now, what about those customers with RTW?
grafikrobot commentedon Mar 28, 2017
Heath Stewart (@heaths) This https://github.com/boostorg/boost/blob/master/bootstrap.bat is the script that checks if you've already built the build system. If not, it tries to build it. If that fails it tells the user some alternatives.
As for RTW people.. Good question. Boost could choose to not support it. Or only support it with a big disclaimer and some user manual configuration (i.e. we'd fail to bootstrap and the message would suggest that if they have RTW they do the manual config).
grafikrobot commentedon Mar 28, 2017
Heath Stewart (@heaths) PS.. Also for RTW customers Microsoft could choose to install vswhere as part of the next OS patch set so that everyone has it installed. Wouldn't help the customers that use OS version that are past end-of-life. But VS2017 probably doesn't run on those.
OlafvdSpek commentedon Mar 30, 2017
René Ferdinand Rivera Morell (@grafikrobot) Why an OS update and not just a VS update?
And why not have users use "Developer Command Prompt for VS 2017" until MS fixes this?
Heath Stewart (@heaths) That's what updates are for.
heaths commentedon Mar 31, 2017
Olaf van der Spek (@OlafvdSpek) users are not forced to take updates for VS. They might have to in some scenarios, but they have never been required. Many organizations want to do rigorous testing before ever taking updates. Even if we did, some users may not be connected or take an update, which means they're on RTW.
OlafvdSpek commentedon Mar 31, 2017
Heath Stewart (@heaths) True, so one might decide not to support RTW..
grafikrobot commentedon Apr 4, 2017
Copying my "solution" from another issue here for the benefit of those in this topic..
Never mind.. After trying to use the vswhere tool to determine the cl.exe location with some modicum of sanity I've given up. My current suggestion will be to avoid this tool and wait for real solution from Microsoft. In the mean time we will tell users that if they want VS2017, aka cl.exe 14.10 (or 14.1 depending on whom you ask) they will need to run from the VS command prompt or set the VS150COMNTOOLS environment variable manually.
Thank you for my wasted time.. Goodbye.
9 remaining items
res2k commentedon Apr 5, 2017
If you're using
vcvarsall.batyou should be fine - it can be found in%dir%\VC\Auxiliary\Build(no version number, yay!).I think build tools for VC <= 14.0 tend use the registry to look for
vcvarsall.batanyway, so doing the same, but viavswhere.exe, is probably not a terribly impractical approach.heaths commentedon Apr 5, 2017
As Tim Sneath (@timsneath) mentioned we will be including vswhere in a well-known location in a subsequent release, so I'm resolving this issue.
OlafvdSpek commentedon Apr 6, 2017
Heath Stewart (@heaths) I'd still like to hear feedback on #41 (comment)
heaths commentedon Apr 6, 2017
Please see my previous comment. A single variable would not capture the granularity of options or which toolset version (now that we ship multiple) and target architecture for native compilation. The suggestion by Frank Richter (@res2k) is a robust solution that will handle that.
OlafvdSpek commentedon Apr 6, 2017
Heath Stewart (@heaths) I know it won't, but that shouldn't stop you from allowing the user to pick one as default..
And please see #41 (comment)
3F commentedon Apr 6, 2017
I updated information about solutions for this issue, and you can also try this if you have similar problem for today.
Tim Sneath (@timsneath), Good ! Thanks.
timsneath commentedon Apr 6, 2017
Denis Kuzmin (@3F), this is awesome. Thanks for going the extra mile here - really appreciate it! When we update the documentation for this area, we'll be sure to link to your repo.
3F commentedon Apr 6, 2017
Tim Sneath (@timsneath),
All are welcome -_*
heaths commentedon Apr 20, 2017
vswhere 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/
OlafvdSpek commentedon Apr 21, 2017
What if the user uses a custom install dir?
refack commentedon Apr 21, 2017
[unofficial answer] Olaf van der Spek (@OlafvdSpek) AFAIK and from own my experience, the custom install dir (which I love and always use) is for the actual VS instance. The installer is always at
%ProgramFiles(x86)%\Microsoft Visual Studio\Installer3F commentedon Apr 21, 2017
Olaf van der Spek (@OlafvdSpek),
As I understand, today there is no way to change path for installer:
I see only
--installPathkey that defines path by default for new instance of VS, and not for installer. The installer still should be appeared in%ProgramFiles(x86)%\Microsoft Visual Studio\Installer(Win-x64) and%ProgramFiles%\Microsoft Visual Studio\Installer(Win-x32). if not, please add path via registry <_<well I checked this. Now we can find vswhere.exe inside this directory. Yey !
Heath Stewart (@heaths), thanks for good news.
Later I will update logic of hMSBuild for new searhing of vswhere (locally and via NuGet).
heaths commentedon Apr 21, 2017
The installer directory is fixed to "%ProgramFilers(x86)%\Microsoft Visual Studio\Installer". If an when we ever move it, we will of course need to maintain at least a symbolic link in that location for vswhere (to other files you find in that directory we make no such guarantee).
sldr commentedon May 11, 2017
Consider:
@echo off for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -version [11^,12^) -property installationPath`) do ( if exist "%%i" ( set VS11INSTALLDIR=%%i set VS11VCVARSALL=%%iVC\vcvarsall.bat ) ) for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -version [12^,13^) -property installationPath`) do ( if exist "%%i" ( set VS12INSTALLDIR=%%i set VS12VCVARSALL=%%iVC\vcvarsall.bat ) ) for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -version [13^,14^) -property installationPath`) do ( if exist "%%i" ( set VS13INSTALLDIR=%%i set VS13VCVARSALL=%%iVC\vcvarsall.bat ) ) for /f "usebackq tokens=*" %%i in ("%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -version [14^,15^) -property installationPath`) do ( if exist "%%i" ( set VS14INSTALLDIR=%%i set VS14VCVARSALL=%%iVC\vcvarsall.bat ) ) for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -version [15^,16^) -property installationPath`) do ( if exist "%%i" ( set VS15INSTALLDIR=%%i set VS15VCVARSALL=%%i\VC\Auxiliary\Build\vcvarsall.bat ) ) REM call "%VS11VCVARSALL%" REM call "%VS12VCVARSALL%" REM call "%VS13VCVARSALL%" REM call "%VS14VCVARSALL%" REM call "%VS15VCVARSALL%" x86 REM call "%VS15VCVARSALL%" x64Just remove REM on one of the last calls for the version you want.
Hope this helps,
SLDR
(Stephen L. De Rudder)
I know it isn't perfect... ;-)