Skip to content

Commit 8563e63

Browse files
committed
Resolve-MsBuild
sort folders by version
1 parent b18c8fa commit 8563e63

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

development/visual-studio/Resolve-MsBuild.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
function Get-Version($pathInfo) {
2+
Get-Item $pathInfo.Path `
3+
| Select-Object VersionInfo `
4+
| % { $_.VersionInfo.FileVersion } `
5+
| % { [version]::Parse($_) }
6+
}
7+
18
function Resolve-MsBuild {
29
$msb2017 = Resolve-Path "${env:ProgramFiles(x86)}\Microsoft Visual Studio\*\*\MSBuild\*\bin\msbuild.exe" -ErrorAction SilentlyContinue
310
if ($msb2017) {
411
Write-Host "Found MSBuild 2017 (or later)." -ForegroundColor Green
5-
return $msb2017 | Select-Object -First 1
12+
return $msb2017 | Sort-Object -Property @{Expression = { Get-Version $_ } } -Descending | Select-Object -First 1
613
}
714

815
$msBuild2015 = "${env:ProgramFiles(x86)}\MSBuild\14.0\bin\msbuild.exe"

0 commit comments

Comments
 (0)