forked from mockingbirdnest/Principia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_msbuild.ps1
34 lines (30 loc) · 1.01 KB
/
find_msbuild.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$version = "16.4.2"
$preview = ""
if ($preview.length -gt 0) {
$description = "version $version preview $preview"
$path = "VisualStudioPreview/$version-pre.$preview."
} else {
$description = "version $version"
$path = "VisualStudio/$version+"
}
$vswhere = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$names = &$vswhere `
-prerelease `
-all `
-requires Microsoft.Component.MSBuild `
-property installationName
$msbuildpaths = &$vswhere `
-prerelease `
-all `
-requires Microsoft.Component.MSBuild `
-find MSBuild\**\Bin\MSBuild.exe
$i = 0;
foreach ($name in $names) {
if ($name.startswith("$path")) {
return ($msbuildpaths | select-object -index $i)
}
++$i
}
write-error(
"Could not find Visual Studio $description;" +
" found the following versions:`n$([string]::join("`n", $names))")