查找 Visual Studio 2017 的 devenv.exe 位置的可靠方法 [英] reliable way to find the location devenv.exe of Visual Studio 2017
问题描述
我需要运行使用 devenv.exe
(或 devenv.com
)构建视觉工作室解决方案的脚本.对于 Visual Studio 2015,有一个环境变量 %VS140COMNTOOLS%
,我可以使用它来查找 devenv 的安装位置.由于 没有 %VS150COMNTOOLS%
对于 Visual Studio 2017,在脚本(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 位置的可靠方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!