Skip to content

Find x64 MSBuild from Locator#135

Merged
Forgind merged 3 commits into
microsoft:masterfrom
Forgind:find-x64-msbuild
Oct 25, 2021
Merged

Find x64 MSBuild from Locator#135
Forgind merged 3 commits into
microsoft:masterfrom
Forgind:find-x64-msbuild

Conversation

@Forgind
Copy link
Copy Markdown
Contributor

@Forgind Forgind commented Sep 20, 2021

Fixes dotnet/msbuild#6681 for pre-17.0 MSBuild.

MSBuild can be loaded from the x86 or x64 folder. Before 17.0, it looked next to the executing assembly in some cases and constructed a path that assumed x86 in others. This overrides the latter assumption to let it find the right MSBuild.

Comment thread src/MSBuildLocator/MSBuildLocator.cs Outdated
}
else
{
string msbuildDll = Path.Combine(path, "MSBuild.dll");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do this for the DLL? I thought the problem was only for .NET Framework x64 applications?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't 100% sure of this, but if you have a .NET Framework app and use RegisterMSBuildPath(<.NET Core MSBuild path>), I think you would have trouble if you tried to use anything that differs between Core and Framework, but you could maybe stick to the overlap and having a working app. Should that be something to care about?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that should fail pretty quickly and if it doesn't today it might tomorrow, as .NET diverges from .NET Framework 4.8. No need to attempt to support it here.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why we should add tests and verify these configurations, perhaps with Docker.

Comment thread src/MSBuildLocator/MSBuildLocator.cs
Comment thread src/MSBuildLocator/MSBuildLocator.cs
Comment thread src/MSBuildLocator/MSBuildLocator.cs
Actually checking for NET46 because that's the only Framework version in the TargetFrameworks, though it would be good to change that eventually.
@Forgind Forgind merged commit 1e9ee03 into microsoft:master Oct 25, 2021
@Forgind Forgind deleted the find-x64-msbuild branch October 25, 2021 15:40
@Forgind Forgind mentioned this pull request Nov 4, 2021
rainersigwald pushed a commit that referenced this pull request Dec 1, 2021
The change in #135 was supposed to be made unnecessary by dotnet/msbuild#6890, but apparently my setup is the only one that has dotnet.exe under both the dotnet folder and the sdks folder, so it didn't work. @xen2 fixed the problem in dotnet/msbuild#7013, but that won't get in 'til 17.1, so we need to prolong the version check here.

Co-authored-by: xen2 <virgile.bello@gmail.com>
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

Successfully merging this pull request may close these issues.

64-bit API clients can wind up with imports that don't match MSBuild.exe/VS's

3 participants