【发布时间】:2017-02-24 09:56:43
【问题描述】:
我有一个 powershell 脚本,它查看 VS 安装列表,并确定安装的最高版本。然后它使用该版本的 InstallDir,并使用它来访问各种命令。
不过,它仍然使用低版本。
从 VS2017 开始,注册表项似乎是 no longer saved in the same way。我需要更新脚本才能弄清楚 2017 年的设置。
#Add New Versions to this list when new versions of VS are released
$VsVersionsToDisable = "10.0", "11.0", "12.0", "14.0"
[System.Collections.ArrayList]$VsVersions = $VsVersionsToDisable
#Find the Highest installed VS Version, and use it for the TFS.exe Command.
foreach ($version in $VsVersions | Sort-Object -Descending)
{
$keyPath = "HKCU:\Software\Microsoft\VisualStudio\$version`_Config"
If (Test-Path $keyPath)
{
$aliasPath = Get-ItemProperty -Path $keyPath | Select-Object `
-ExpandProperty InstallDir
$proxyPath = Join-Path $aliasPath "tf.exe"
set-alias proxyTF $proxyPath
}
}
为避免 XY 问题:我们使用此脚本为用户配置 TFS 代理设置。它确定安装的最高版本,使用它来查找代理,然后遍历较低版本,使用相同的值配置其代理设置。
确定 VS2017 的安装目录(以及 tf.exe 位置)的最佳方法是什么?
【问题讨论】:
标签: powershell tfs registry visual-studio-2017