以编程方式查找VS2017安装目录

以编程方式查找VS2017安装目录

本文介绍了以编程方式查找VS2017安装目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以前版本的 VS,您可以查询注册表以确定 VS 的安装目录:

With previous versions of VS you could query the registry to determine the installation directory for VS:

HKLMSOFTWAREWow6432NodeMicrosoftVisualStudio14.0

但是,这似乎不适用于 VS2017 RC.我们有脚本可以检测最新安装的 VS,然后做正确的事情",到目前为止,我在将 VS2017 插入这些系统时遇到问题.

However, this doesn't seem to work with the VS2017 RC. We have scripts that detect the latest installed VS and then do "the right thing", and so far I'm having issues plugging VS2017 into those systems.

有人知道如何以编程方式确定 VS2017 的安装位置吗?

Does anyone know how to programmatically determine the installation location for VS2017?

推荐答案

可以使用vswhere 获取 VS2017 位置的工具.

You can use vswhere tool to get VS2017 location.

例子:

@echo off

rem VS2017U2 contains vswhere.exe
if "%VSWHERE%"=="" set "VSWHERE=%ProgramFiles(x86)%Microsoft Visual StudioInstallervswhere.exe"

for /f "usebackq tokens=*" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
  set InstallDir=%%i
)

if exist "%InstallDir%MSBuild15.0BinMSBuild.exe" (
  "%InstallDir%MSBuild15.0BinMSBuild.exe" %*
)

您可以在此处阅读更多信息:https:///blogs.msdn.microsoft.com/heaths/2017/02/25/vswhere-available/

You can read more about it here: https://blogs.msdn.microsoft.com/heaths/2017/02/25/vswhere-available/

这篇关于以编程方式查找VS2017安装目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:24