问题描述
我需要运行使用devenv.exe
(或devenv.com
)构建Visual Studio解决方案的脚本.对于Visual Studio 2015,我可以使用一个环境变量%VS140COMNTOOLS%
来找到 devenv 的安装位置.由于对于Visual Studio 2017没有%VS150COMNTOOLS%
,这是在脚本(bat或powershell)中找到devenv
安装位置的可靠方法.
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).
推荐答案
您可以使用vswhere.exe
或powershell来找到您的Visual Studio实例:
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
)
和
Install-Module VSSetup -Scope CurrentUser
Get-VSSetupInstance | Select-VSSetupInstance -Latest -Require Microsoft.VisualStudio.Component.VC.Tools.x86.x64
也可以通过此api找到指向特定工作负载的路径.
The path to specific workloads can be found through this api as well.
这篇关于查找Visual Studio 2017位置devenv.exe的可靠方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!