nightroman / Invoke-Build

Build Automation in PowerShell

Home Page:https://github.com/nightroman/Invoke-Build/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Resolve-MSBuild 17.0 and VS 2022 Build Tools

mikedoerfler opened this issue · comments

I believe there is an issue with Resolve-MSBuild 17.0 and having just the VS 2022 Build Tools installed instead of the full Visual Studio 2022. The Build Tools appear to install in"$Program86\Microsoft Visual Studio\2022". If I am reading the Resolve-MSBuild.ps1 file correctly - when it attempts to guess the location of 17.0 it will only look in C:\Program Files for 64 bit.

Nice. Logical, is not it... Let me think about this.
Just in case, can anybody else confirm this unexpected location? Any MS documentation mentioning this?
Do you have VSSetup module? If not, can you try it for the time being as a workaround? If it works of course.

I mean just try install the PS module VSSetup and try again. If VSSetup is installed and it gets the correct location then IB should work - it sees and uses VSSetup instead of guessing paths.

Could you please do this test and let me know the results?
Thank you.

As for the fix, in the function Get-MSBuild15Guess I am going to add these lines (marked #188)

		elseif ($Version -eq '*') {
			"$Program64\Microsoft Visual Studio\2022"
			"$Program86\Microsoft Visual Studio\2022" #188
			"$Program86\Microsoft Visual Studio\2019"
			"$Program86\Microsoft Visual Studio\2017"
		}
		elseif ($Version -eq '17.0') {
			"$Program64\Microsoft Visual Studio\2022"
			"$Program86\Microsoft Visual Studio\2022" #188
		}

If you can try adding these line and let me know it works for you, this would be nice.
NB But first uninstall VSSetup, if you installed for the previous experiment.

Good morning Roman - I modified my local Resolve-MSBuild.ps1 file and the build is now finding the 2022 build tools.

MSBuild auto-detection: using msbuild version '17.0.0.52104' from 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\bin'.

You modified as I suggested above, right?
Not quite sure where your message comes from, I do not remember such in IB.

Good afternoon Roman - yes, I modified the file using the lines with the comments #188 from above.

You are correct about the MSBuild auto-detection not being from IB, sorry about that, it came from NuGet.exe. I did find entries in the build log indicating that the csc.exe being used was:

C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\Roslyn\csc.exe

So it looks like those #188 lines added above resolve to the 2022 Build Tools.

Last question, just to double check, you installed VS Build Tools with all defaults, right?

I believe I left defaults alone. All I choose when installing was the web build tools and desktop build tools. I did not change paths or anything else when walking through installer.

5.8.6