MSBuildLocator icon indicating copy to clipboard operation
MSBuildLocator copied to clipboard

Version 1.5.3 misses a trailing directory separator path

Open CamiloTerevinto opened this issue 3 years ago • 0 comments

In a project, where the MS Build instance is registered with MSBuildLocator.RegisterDefaults(); before calling a method that ends up doing:

var globalProperties = new Dictionary<string, string>
{
    { "SolutionDir", $"{Path.GetDirectoryName("path")}{Path.DirectorySeparatorChar}" }
};
var projectCollection = new ProjectCollection(globalProperties);
var project = projectCollection.LoadProject("path");

Both the above and doing just new Project("path"); fails with an InvalidProjectFileException.

Looking at the ProjectCollection, the difference between Microsoft.Build.Locator 1.4.1 and 1.5.3 is in ProjectCollection.Toolsets[0]._properties[0].

1.4.1: "MSBuildSDKsPath"="C:\\Program Files\\dotnet\\sdk\\6.0.303\\Sdks" 1.5.3: "MSBuildSDKsPath"="C:\\Program Files\\dotnet\\sdk\\6.0.303Sdks"

This might need to be fixed in the Microsoft.Build.Evaluation package instead of here, though.

CamiloTerevinto avatar Aug 14 '22 10:08 CamiloTerevinto