Skip to content

slnf file handling requires the use of Windows-style directory separators in order to be built on all platforms #12729

@baronfel

Description

@baronfel

Issue Description

I have a slnf in the SDK repo that looks like this:

{
  "solution": {
    "path": "sdk.slnx",
    "projects": [
      "src/BuiltInTools/dotnet-watch/dotnet-watch.csproj",
      "src/Cli/dotnet/dotnet.csproj",
      "src/Cli/Microsoft.DotNet.Cli.Utils/Microsoft.DotNet.Cli.Utils.csproj",
      "test/Microsoft.NET.TestFramework/Microsoft.NET.TestFramework.csproj",
      "test/dotnet-watch.Tests/dotnet-watch.Tests.csproj",
      "test/dotnet.Tests/dotnet.Tests.csproj",
      "test/Microsoft.DotNet.Cli.Utils.Tests/Microsoft.DotNet.Cli.Utils.Tests.csproj"
    ]
  }
}

and when I build it I get the following error:

error MSB4025: The project file could not be loaded. Microsoft.Build.Exceptions.InvalidProjectFileException: Solution filter file at "D:\Code\dotnet-sdk\cli.slnf" includes project "src/Cli/dotnet/dotnet.csproj" that is not in the solution file at "D:\Code\dotnet-sdk\sdk.slnx".  
    at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args)
    at Microsoft.Build.Construction.SolutionFile.ValidateProjectsInSolutionFilter()
    at Microsoft.Build.Construction.SolutionFile.ReadSolutionModel(SolutionModel solutionModel)
    at Microsoft.Build.Construction.SolutionFile.ParseUsingNewParser()

Yet the project does exist in the slnx file:

<Solution>
  ...
 <Folder Name="/src/BuiltInTools/">
    ...
    <Project Path="src/BuiltInTools/dotnet-watch/dotnet-watch.csproj" />
    ...
  </Folder>
  ...
</Solution>

When I change the slnf to use Windows-style paths (swap \\ for /) then the projects are found. We should support Unix-style paths in slnf files.

Steps to Reproduce

  • create a slnx
  • create a project
  • add the project to the slnx
  • create a slnf file
  • add the project to the slnf with Unix-style paths
  • dotnet build the slnf
  • see the error

Expected Behavior

The slnf is able to be applied to the slnx file.

Actual Behavior

The projects in the slnf aren't found in the slnx and so the error is raised.

(This is one area where the solution-parsing library fully supporting slnf would solve this one time, for everyone)

Analysis

No response

Versions & Configurations

No response

Metadata

Metadata

Assignees

Labels

Area: Solution (.sln)Issues related to parsing .sln files or building solutions

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions