Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper handling of slashes in solution files #2022

Closed
Sumo-MBryant opened this issue Apr 28, 2017 · 6 comments
Closed

Improper handling of slashes in solution files #2022

Sumo-MBryant opened this issue Apr 28, 2017 · 6 comments
Assignees
Labels
Area: Solution (.sln) Issues related to parsing .sln files or building solutions bug triaged xplat

Comments

@Sumo-MBryant
Copy link

If a solution file contains a relative path to a project with a backslash (which Visual Studio and dotnet sln add both emit), and the project uses a project type GUID that is not recognised by MSBuild, any attempts to build the solution on Linux fail with the error:

{path_to_project}.metaproj : error MSB4025: The project file could not be loaded. Could not find file '{path_to_project}.metaproj'.

It appears that the code in Microsoft.Build.Construction.ProjectInSolution.CanBeMSBuildProjectFile() is failing on Linux.

Reproduction Steps:

  1. Create a solution file named solution.sln with the following contents:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("AAAAAAAA-1760-4266-BCC7-CA923CBCF16C") = "project", "directory\project.proj", "{1FD5F8F7-D4D3-4760-B503-03883D7CDFD7}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{1FD5F8F7-D4D3-4760-B503-03883D7CDFD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{1FD5F8F7-D4D3-4760-B503-03883D7CDFD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
	EndGlobalSection
EndGlobal
  1. Create a project file project.proj in a sub directory named directory with the following contents:
<Project>
  <PropertyGroup>
    <DefaultProjectTypeGuid>AAAAAAAA-1760-4266-BCC7-CA923CBCF16C</DefaultProjectTypeGuid>
  </PropertyGroup>

  <Target Name="Build">
    <Message Text="Build target for $(MSBuildProjectFile)" Importance="high" />
  </Target>
</Project>
  1. On Linux, run dotnet msbuild solution.sln

Expected Output:

  Build target for project.proj

Actual Output:

project.proj.metaproj : error MSB4025: The project file could not be loaded. Could not find file '/homeproject.proj.metaproj'.

Workaround

Replace all backslashes in the solution file with forward slashes in the solution file.

@rainersigwald
Copy link
Member

At a quick glance, I bet we we need a MaybeAdjustFilePath() about here.

@rainersigwald rainersigwald added bug Area: Solution (.sln) Issues related to parsing .sln files or building solutions xplat labels Apr 28, 2017
@radical
Copy link
Member

radical commented Apr 28, 2017

I get the same error on mac, with dotnet 1.0.3: dotnet build foo.sln.
But with msbuild/mono (even few months old 4.8.0) it works fine.

$ dotnet build -version
Microsoft (R) Build Engine version 15.1.1012.6693

@kellypleahy
Copy link

Seems like this would be nice to get fixed before .NET core 2.0 ships. Is that still a possibility? Who would need to be involved?

@radical
Copy link
Member

radical commented Jun 8, 2017

I have mono@28dc2d4 and mono@86adc96 . I'll open a PR.

@radical
Copy link
Member

radical commented Jun 8, 2017

Ah, the base patch is already in, so only the actual fix is required.

@dmitriyse
Copy link

Linux, dotnet-sdk-2.0.3
Command:

dotnet msbuild /t:MyProject:build MySolution.sln

do nothing

But on windows it works. This command builds only MyProject project from the MySolution.sln

Konard referenced this issue in Konard/LinksPlatform Nov 30, 2017
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Feb 7, 2018
Add a test that will fail on forward-slash OSes when reading a
backslash-containing relative path from a solution file.

Regression test for dotnet#2022.
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Feb 7, 2018
Add a test that will fail on forward-slash OSes when reading a
backslash-containing relative path from a solution file.

Regression test for dotnet#2022.
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Feb 7, 2018
rainersigwald added a commit to rainersigwald/msbuild that referenced this issue Feb 7, 2018
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Solution (.sln) Issues related to parsing .sln files or building solutions bug triaged xplat
Projects
None yet
Development

No branches or pull requests

8 participants