msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

ProjectInSolution.AbsolutePath contains '\' on Mac OS/Linux

Open dazhao-msft opened this issue 8 years ago • 1 comments

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();
		}
	}

dazhao-msft avatar Feb 28 '17 19:02 dazhao-msft

Right now we just Path.Combine the relative path with the solution file directory. Perhaps we should normalize _relativePath in its setter?

rainersigwald avatar Feb 28 '17 19:02 rainersigwald