2017-01-24 04:53:18 +08:00
|
|
|
[CmdletBinding()]
|
|
|
|
param(
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
$scriptsDir = split-path -parent $MyInvocation.MyCommand.Definition
|
2017-10-06 09:25:34 +08:00
|
|
|
$vswhereExe = & $scriptsDir\fetchDependency.ps1 "vswhere"
|
2017-01-24 04:53:18 +08:00
|
|
|
|
2017-10-10 07:38:21 +08:00
|
|
|
$output = & $vswhereExe -prerelease -legacy -products * -format xml
|
2017-10-06 09:25:34 +08:00
|
|
|
[xml]$asXml = $output
|
2017-01-24 04:53:18 +08:00
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
$results = New-Object System.Collections.ArrayList
|
|
|
|
foreach ($instance in $asXml.instances.instance)
|
2017-01-24 04:53:18 +08:00
|
|
|
{
|
2017-10-06 09:25:34 +08:00
|
|
|
$installationPath = $instance.InstallationPath -replace "\\$" # Remove potential trailing backslash
|
|
|
|
$installationVersion = $instance.InstallationVersion
|
|
|
|
$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("${releaseType}::${installationVersion}::${installationPath}") > $null
|
2017-01-24 04:53:18 +08:00
|
|
|
}
|
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
$results.Sort()
|
|
|
|
$results.Reverse()
|
2017-01-24 04:53:18 +08:00
|
|
|
|
2017-10-06 09:25:34 +08:00
|
|
|
return $results
|