I need to run scripts that build a visual studio solutions using devenv.exe
(or devenv.com
for that matter). For visual studio 2015 there was an environment variable %VS140COMNTOOLS%
that I could use to find the install location of devenv. Since there is no %VS150COMNTOOLS%
for Visual Studio 2017, what would be a reliable way to find the install location of devenv
in a script (bat or powershell).
You can use vswhere.exe
or powershell to find your Visual Studio instances:
for /r "usebackq tokens=1* delims=: " %%i in (`vswhere.exe -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop`) do (
if /i "%%i"=="installationPath" set dir=%%j
)
and
Install-Module VSSetup -Scope CurrentUser
Get-VSSetupInstance | Select-VSSetupInstance -Latest -Require Microsoft.VisualStudio.Component.VC.Tools.x86.x64
The path to specific workloads can be found through this api as well.