Skip to content

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

Open
@dazhao-msft

Description

@dazhao-msft

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

Metadata

Metadata

Assignees

Labels

Area: APIArea: Solution (.sln)Issues related to parsing .sln files or building solutionshelp wantedIssues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim.triaged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions