aboutsummaryrefslogtreecommitdiff
path: root/scripts/getVisualStudioInstances.ps1
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-05-05 04:23:19 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2018-05-15 23:27:14 -0700
commit1b0682a39e1143660c3d5aa371f66591a64e8a5d (patch)
treefed8de963661a5176f70b74b91ab1cef7bf00a74 /scripts/getVisualStudioInstances.ps1
parent52f01eefa6e1da7a9458807a1eb3d288ecd50613 (diff)
downloadvcpkg-1b0682a39e1143660c3d5aa371f66591a64e8a5d.tar.gz
vcpkg-1b0682a39e1143660c3d5aa371f66591a64e8a5d.zip
[vcpkg] Significantly reduce usage of powershell. Reduce console font switching bug
Diffstat (limited to 'scripts/getVisualStudioInstances.ps1')
-rw-r--r--scripts/getVisualStudioInstances.ps174
1 files changed, 74 insertions, 0 deletions
diff --git a/scripts/getVisualStudioInstances.ps1 b/scripts/getVisualStudioInstances.ps1
new file mode 100644
index 000000000..83b0b8ebd
--- /dev/null
+++ b/scripts/getVisualStudioInstances.ps1
@@ -0,0 +1,74 @@
+[CmdletBinding()]
+param(
+
+)
+Set-StrictMode -Version Latest
+$scriptsDir = split-path -parent $script:MyInvocation.MyCommand.Definition
+. "$scriptsDir\VcpkgPowershellUtils.ps1"
+
+$programFiles = getProgramFiles32bit
+
+$results = New-Object System.Collections.ArrayList
+
+$vswhereExe = "$programFiles\Microsoft Visual Studio\Installer\vswhere.exe"
+
+if (Test-Path $vswhereExe)
+{
+ $output = & $vswhereExe -prerelease -legacy -products * -format xml
+ [xml]$asXml = $output
+
+ foreach ($instance in $asXml.instances.instance)
+ {
+ $installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
+ $installationVersion = $instance.InstallationVersion
+
+ $isPrerelease = -7
+ if (vcpkgHasProperty -object $instance -propertyName "isPrerelease")
+ {
+ $isPrerelease = $instance.isPrerelease
+ }
+
+ if ($isPrerelease -eq 0)
+ {
+ $releaseType = "PreferenceWeight3::StableRelease"
+ }
+ elseif ($isPrerelease -eq 1)
+ {
+ $releaseType = "PreferenceWeight2::PreRelease"
+ }
+ else
+ {
+ $releaseType = "PreferenceWeight1::Legacy"
+ }
+
+ # Placed like that for easy sorting according to preference
+ $results.Add("<sol>::${releaseType}::${installationVersion}::${installationPath}::<eol>") > $null
+ }
+}
+else
+{
+ Write-Verbose "Could not locate vswhere at $vswhereExe"
+}
+
+$installationPath = Split-Path -Parent $(Split-Path -Parent "$env:vs140comntools")
+$clExe = "$installationPath\VC\bin\cl.exe"
+$vcvarsallbat = "$installationPath\VC\vcvarsall.bat"
+
+if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat))
+{
+ $results.Add("<sol>::PreferenceWeight1::Legacy::14.0::$installationPath::<eol>") > $null
+}
+
+$installationPath = "$programFiles\Microsoft Visual Studio 14.0"
+$clExe = "$installationPath\VC\bin\cl.exe"
+$vcvarsallbat = "$installationPath\VC\vcvarsall.bat"
+
+if ((Test-Path $clExe) -And (Test-Path $vcvarsallbat))
+{
+ $results.Add("<sol>::PreferenceWeight1::Legacy::14.0::$installationPath::<eol>") > $null
+}
+
+$results.Sort()
+$results.Reverse()
+
+return $results