Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating the Get-MsBuildPath function #422

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions common-npm-packages/msbuildhelpers/PathFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,38 @@ function Get-MSBuildPath {
# found is returned instead. Same for "16.0" and "17.0"
[System.Reflection.Assembly]$msUtilities = $null


# We do not need Microsoft.Build.Utilities.Core.dll - if we have located this .dll file, we also have the location of msbuild.exe
# for the Bitness32 variant since it resides in the same folder.
# and for the Bitness64 variant since it resides in the /amd64 folders.
# These paths are fixed due to the way VS is installed.
$VersionNumber = [int]($Version.Remove(2))

Write-Output "version: $VersionNumber"
$specifiedStudio = Get-VisualStudio $VersionNumber
Write-Output $specifiedStudio
if (($VersionNumber -ge 16 -or !$Version) -and # !$Version indicates "latest"
($specifiedStudio = Get-VisualStudio $VersionNumber) -and
$specifiedStudio.installationPath) {

$msbuildUtilitiesPath = [System.IO.Path]::Combine($specifiedStudio.installationPath, "MSBuild\Current\Bin\Microsoft.Build.Utilities.Core.dll")
if (Test-Path -LiteralPath $msbuildUtilitiesPath -PathType Leaf) {
Write-Verbose "Loading $msbuildUtilitiesPath"
$msUtilities = [System.Reflection.Assembly]::LoadFrom($msbuildUtilitiesPath)
}
}
[object]$archValue = $null
if ($Architecture -eq 'x86') {
$msBuildPath = [System.IO.Path]::Combine($specifiedStudio.installationPath, "MSBuild\Current\Bin\msbuild.exe")
# DotNetFrameworkArchitecture.Bitness32
} elseif ($Architecture -eq 'x64') {
$msBuildPath = [System.IO.Path]::Combine($specifiedStudio.installationPath, "MSBuild\Current\Bin\amd64\msbuild.exe")
# DotNetFrameworkArchitecture.Bitness64
} else {
$msBuildPath = [System.IO.Path]::Combine($specifiedStudio.installationPath, "MSBuild\Current\Bin\msbuild.exe")
# DotNetFrameworkArchitecture.Bitness32
}

if ($msBuildPath -and (Test-Path -LiteralPath $msBuildPath -PathType Leaf)) {
Write-Verbose "MSBuild: $msBuildPath"
return $msBuildPath
}
}


elseif (($Version -eq "15.0" -or !$Version) -and # !$Version indicates "latest"
($visualStudio15 = Get-VisualStudio 15) -and
Expand Down