查找Visual Studio 2017位置devenv.exe的可靠方法 [英] reliable way to find the location devenv.exe of Visual Studio 2017

查看:880
本文介绍了查找Visual Studio 2017位置devenv.exe的可靠方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行使用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.

查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆