Skip to content

[Regression] dotnet sln add with 2 projects on the same directory produces an invalid solution #51970

@ceztko

Description

@ceztko

Describe the bug

Creating a solution using dotnet sln add with 2 projects presents on the same directory produces a non working solution. The error is the following as when opening the solution in VS2022:

Image

It has been present since when I upgraded to (around) VS 2022 17.14.19. I can reproduce with the last VS 2022 maintenance version 17.14.21, which has dotnet SDK 9.0.308 and 8.0.416. I have a linux box that ships with older SDKs 9.0.107/8.0.117 where I don't reproduce.

To Reproduce

Uncompress TestDotnetSlnAddProject.zip and run bootstrap.ps1 which does:

dotnet new sln --name TestDotnetSlnAddProject --force
dotnet sln TestDotnetSlnAddProject.sln add TestDotnetSlnAddProject/TestDotnetSlnAddProject.csproj TestDotnetSlnAddProject/TestDotnetSlnAddProject2.csproj
dotnet restore TestDotnetSlnAddProject.sln

Exceptions (if any)

dotnet restore outputs:

Solution file error MSB5004: The solution file has two projects named "TestDotnetSlnAddProject".

Opening in Visual Studio:

"The solution folder cannot be added to the solution because a Solution Folder with the same unique identifier already exits"

Further technical details

details of dotnet --info

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions