Closed MichaelGrafnetter closed 7 years ago
We are considering it, but how we find that information and what we can yield is very different. See Microsoft/vswhere#24 for details.
Also, vswhere might have a better chance getting this functionality. These cmdlets provide much richer information and is meant more for deeper analysis not exposed by vswhere. Much of that information just isn't available for older installs. The setup engine was completely redesigned and rewritten from previous deployments
OK, I get it. It just seemed more logical to me to call a PS cmdlet from a PS build script.
In my build workflows, I only need to locate the newest VsDevCmd.bat file, which might be here C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\ or here C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common\Tools\ etc.
vswhere works great with powershell and is a single-file redistributable EXE:
$path = vswhere -latest -property installationPath
If you want to get a couple properties, you can do something like this:
$instance = vswhere -latest -format json
"Instance {0} installed to: {1}" -f $instance.instanceId, $instance.installationPath
Depending on your environment, redistributing vswhere may be a better option to having to run install-module
to install the module on other machines.
Thx for the nice sample code.
Just a sidenote, there is no need to run Install-Module at all. I have the module in Git repo and call this to import it from a build script:
$modulePath = Join-Path $PSScriptRoot 'Modules\VSSetup' Import-Module $modulePath -ErrorAction Stop
If you're checking in the module, vswhere would be a smaller (and likely faster) option as well if you're just getting the installation path. We've talked it over and agree that because the cmdlets provide much richer information not available for older installs, we won't add support for older installs to the cmdlts. We are still considering support in vswhere, though, so feel free to cast on a vote there if you like.
Thanks for the feedback!
First of all, great module, very useful in build scripts!
I am mainstaining a couple of projects where it is desirable that they are buildable using previous versions of VS / tools. I therefore had to create a wrapper around VSSetup to be able to locate VS 2013 and 2015 too.
It would be nice if the VSSetup supported at least 2 previous VS versions natively.