microsoft/MSBuildLocator

Support applications carrying a fallback MSBuild

rainersigwald opened this issue · 0 comments

Locator works if you have an installed VS, but it would be nice to be able to support (at least partially) building .NET Core SDK projects on a machine with only the .NET Core SDK installed and not VS.

docfx does this currently by shipping and loading an app-local MSBuild, and then finding and pointing MSBUILD_EXE_PATH and friends to the SDK install. dotnet/docfx#2248

But that requires delivering MSBuild assemblies in the default load location next to the user application, which means that those assemblies are always loaded. That defeats the purpose of Locator.

Instead, we could provide a way to manually specify a fallback location into which the user has set up the Microsoft.Build.Runtime package. Then a user could

var instances = MSBuildLocator.QueryVisualStudioInstances();
if (instances.Any())
{
    MSBuildLocator.RegisterInstance(instances.First());
}
else
{
    MSBuild.RegisterPrivate(pathToPrivateMSBuildRuntime);
}