microsoft / MSBuildLocator

An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
218 stars 83 forks source link

Load core NuGet assemblies. #93

Closed Chryssie closed 3 years ago

Chryssie commented 4 years ago

This should fix #86 and has done so in a project I work on.

ghost commented 4 years ago

CLA assistant check
All CLA requirements met.

rainersigwald commented 3 years ago

@chryssie Thanks! Was the project you work on .NET Core or .NET Framework based? I believe the NuGet assemblies aren't in the folder next to MSBuild for Visual Studio (/.NET Framework MSBuild) scenarios.

mhutch commented 3 years ago

FWIW I used this patch from a test project and it broke ("MSBuild assemblies were already loaded" error) because the test SDK (Microsoft.NET.Test.Sdk etc) brings in NuGet.Frameworks and loads it before any of the locator code can run.

rainersigwald commented 3 years ago

Thanks, @mhutch! @Forgind, sounds like more evidence we should go with the approach in #107 that makes assemblies available but doesn't complain if they're already loaded.

Note that #107 alone won't fix the NuGet problem because NuGet isn't next to MSBuild in VS scenarios, but I think it'll work for Core.

rainersigwald commented 3 years ago

Since this by itself causes a problem and #107 should fix both, closing this. Thanks again @Chryssie!

Forgind commented 3 years ago

Do you think it would make sense to also add that we look in Path.Combine(msbuildPath, "..", "..", "..", "Common7", "IDE", "CommonExtensions", "Microsoft", "NuGet") for anything starting with "NuGet" and ending in ".dll"?

rainersigwald commented 3 years ago

@forgind I think that's a reasonable start to tackling #86 for VS, yes.