in src/MSBuildLocator/MSBuildLocator.cs [112:136]
public static void RegisterInstance(VisualStudioInstance instance)
{
if (instance == null)
{
throw new ArgumentNullException(nameof(instance));
}
if (instance.DiscoveryType == DiscoveryType.DotNetSdk)
{
// The dotnet cli sets up these environment variables when msbuild is invoked via `dotnet`,
// but we are using msbuild dlls directly and therefore need to mimic that.
ApplyDotNetSdkEnvironmentVariables(instance.MSBuildPath);
}
// Find and load NuGet assemblies if msbuildPath is in a VS installation
string nugetPath = Path.GetFullPath(Path.Combine(instance.MSBuildPath, "..", "..", "..", "Common7", "IDE", "CommonExtensions", "Microsoft", "NuGet"));
if (Directory.Exists(nugetPath))
{
RegisterMSBuildPath(new string[] { instance.MSBuildPath, nugetPath });
}
else
{
RegisterMSBuildPath(instance.MSBuildPath);
}
}