Skip to content

dotnet sln add command inconsistent behaviour in .NET SDK 9.0.2xx #46891

@davidsekar

Description

@davidsekar

Describe the bug

There is an inconsistency while adding csproj to a solution file. This behaviour started after dotnet CLI moved to .NET SDK 9.0.2xx

To Reproduce

  • Create a console application named "My.Name.Dot"
    This creates a solution within "C:\Users\User.Name\source\repos\My.Name.Dot" and the project is placed within "C:\Users\User.Name\source\repos\My.Name.Dot\My.Name.Dot\My.Name.Dot.csproj"

  • Just for testing remove My.Name.Dot.csproj from the solution
    dotnet sln "My.Name.Dot.sln" remove "C:\Users\User.Name\source\repos\My.Name.Dot\My.Name.Dot\My.Name.Dot.csproj"
    and re-add with following command
    dotnet sln "My.Name.Dot.sln" add "C:\Users\User.Name\source\repos\My.Name.Dot\My.Name.Dot\My.Name.Dot.csproj"
    The project gets added to solution as expected

  • Now copy the csproj folder outside of this solution under "C:\Users\User.Name\source\repos\My.Name.Dot1\My.Name.Dot1.csproj"
    Now try to add this csproj to the solution as follows

dotnet sln "My.Name.Dot.sln" add "C:\Users\User.Name\source\repos\My.Name.Dot1\My.Name.Dot1.csproj"

This strangely throws an exception

Exceptions (if any)

Names cannot:

  • contain any of the following characters: / ? : \ * " < > |
  • contain control characters
  • be system reserved names, including 'CON', 'AUX', 'PRN', 'COM1' or 'LPT2'
  • be '.' or '..' (Parameter 'name')

Further technical details

dotnet --info
.NET SDK:
Version: 9.0.200
Commit: 90e8b20
Workload version: 9.0.200-manifests.c4f6226a
MSBuild version: 17.13.8+cbc39bea8

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.200\

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions