Pentia.Get-MSBuild.psm1

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
<#
.SYNOPSIS
Gets the path to highest version of MSBuild.exe installed on the system.
 
.EXAMPLE
Get-MSBuild
#>

function Get-MSBuild {
    [CmdletBinding()]
    [OutputType([string])]
    param ()
    
    Write-Verbose "Searching for MSBuild.exe."
    $msBuildExecutable = Invoke-hMSBuildBat
    if ($null -eq $msBuildExecutable -or !(Test-Path $msBuildExecutable)) {
        throw "Didn't find MSBuild.exe."
    }
    Write-Verbose "Found MSBuild.exe at '$msBuildExecutable'."
    $msBuildExecutable
}

function Invoke-hMSBuildBat {
    . "$PSScriptRoot\lib\hMSBuild.bat" "-only-path"
}

Export-ModuleMember -Function Get-MSBuild