msbuild
msbuild copied to clipboard
ProjectInSolution.AbsolutePath contains '\' on Mac OS/Linux
The problem appears to be that the '\' comes from the relative path of the project defined in the .sln files. When MSBuild reads the paths, it doesn't properly convert to the right directory separator based on the OS that is currently running.
Here is the code that can repro the issue:
class MainClass
{
public static void Main(string[] args)
{
var projectPaths = SolutionFile.Parse("/Users/dazhao/Projects/ProjectInSolutionRepro/ProjectInSolutionRepro.sln")
.ProjectsInOrder
.Where(p => p.ProjectType != SolutionProjectType.SolutionFolder)
.Select(p => p.AbsolutePath)
.ToList();
foreach (var projectPath in projectPaths)
{
Console.WriteLine(projectPath);
}
// The output is /Users/dazhao/Projects/ProjectInSolutionRepro/ProjectInSolutionRepro\ProjectInSolutionRepro.csproj
Console.Read();
}
}
Right now we just Path.Combine the relative path with the solution file directory. Perhaps we should normalize _relativePath in its setter?