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

Does not use msbuild 15 automatically #85

Open
czechdude opened this issue Oct 3, 2017 · 2 comments
Open

Does not use msbuild 15 automatically #85

czechdude opened this issue Oct 3, 2017 · 2 comments

Comments

@czechdude
Copy link

czechdude commented Oct 3, 2017

Hi,
if I'm not mistaken, msbuild 15 is not detected and used automatically when VS Buildtools 2017 installed. The path changed to
c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe

Or in case VS installed (look out for the edition dir name)
c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe

Thanks for fixing (or correcting me) :)

Petr

@sayedihashimi
Copy link
Member

Hi @czechdude the issue is that I haven't found a way to discover where MSBuild is installed with VS2017. They are no longer writing to the standard windows registry.

@czechdude
Copy link
Author

My coleague solved it adding a function into psbuild.psm1, unfortunatelly it expects some standard installation paths

<#
.SYNOPSIS  
    This will return the path to msbuild.exe version 15 if installed to defualt location.
.PARAMETER bitness
    Determines wheter the 32 or 64-bit version of msbuild.exe is returned.
    32 bit is the default.
#>
function Get-MSBuild15Guess {
       [cmdletbinding()]
    param(
        [Parameter(Position=0)]
        [ValidateSet('32bit','64bit')]
        [string]$bitness = '32bit'
    )
    process{
        $root = ${env:ProgramFiles(x86)}        
        if (!$root){
            $root = $env:ProgramFiles
        }
        if (Test-Path -LiteralPath "$root\Microsoft Visual Studio\2017") 
        {
            $subFolder = ""
            if($bitness -eq '64bit'){ $subFolder = "amd64" }
            $rp = @(Resolve-Path "$root\Microsoft Visual Studio\2017\*\MSBuild\15.0\Bin\$subFolder\MSBuild.exe" -ErrorAction 0)
            if ($rp) 
            {
                return $rp[-1].ProviderPath
            }
        }
    }
}

And then calling it in Get-MSBuild function:

            $msbuild15pathGuess = Get-MSBuild15Guess -bitness $bitness
            $msbuild15Found = $msbuild15pathGuess -ne $null
            if($msbuild15Found){
                return $msbuild15pathGuess
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants