Skip to content

Dotnet add project to solution command just fails starting with newest 9.x SDK #46771

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

Closed
xafero opened this issue Feb 12, 2025 · 6 comments
Closed
Labels
Area-CLI untriaged Request triage from a team member

Comments

@xafero
Copy link

xafero commented Feb 12, 2025

Describe the bug

I very often use the add-command to add newly created projects to my solution. Now it just simply fails without any sense or reason. It would seem that it tries to take my path to a project as the name of the item-to-be-added? Crazy. Because in the past versions (I have to downgrade to .NET 8 for now), it of course reads the referenced project file and just works.

To Reproduce

c:\Code\some>dotnet sln add ..\common\Data.Forms
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')

c:\Code\some>dotnet --list-sdks
1.1.0 [C:\Program Files\dotnet\sdk]
3.1.426 [C:\Program Files\dotnet\sdk]
5.0.408 [C:\Program Files\dotnet\sdk]
6.0.136 [C:\Program Files\dotnet\sdk]
6.0.321 [C:\Program Files\dotnet\sdk]
9.0.200 [C:\Program Files\dotnet\sdk]

Until .NET 8.0.406 at least, the same command actually works and adds my project to the solution.

Why, on Earth, did this awful change happen? Please fix this. I'm mostly working in command-line.

@ghost ghost added Area-CLI untriaged Request triage from a team member labels Feb 12, 2025
@baronfel
Copy link
Member

@edvilme is this another example of the relative path bug that you've fixed already? If so, the fix will be in next month's release.

@edvilme
Copy link
Member

edvilme commented Feb 12, 2025

Yes, when the project path gets resolved, it attempts to create solution folder ".." which as the error suggests is not valid. A fix for this has already been merged for 9.0.2xx. See #46456

@baronfel
Copy link
Member

Thanks for confirming! I'll close this as it's been fixed by #46456, then. @xafero you should be good to go next month when 9.0.201 releases.

@baronfel baronfel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 12, 2025
@sahin52
Copy link

sahin52 commented Feb 19, 2025

The same error happens when you try to add a project to solution with full name:
dotnet sln .\my.sln add C:\tmp\my.csproj

@edvilme
Copy link
Member

edvilme commented Feb 19, 2025

The same error happens when you try to add a project to solution with full name:
dotnet sln .\my.sln add C:\tmp\my.csproj

Yes, this is due to the relative project location being outside of the solution working directory. Hence it eventually gets resolved to ../../tmp/my.csproj

@faultyblaster
Copy link

The same error happens when you try to add a project to solution with full name:
dotnet sln .\my.sln add C:\tmp\my.csproj

Yes, this is due to the relative project location being outside of the solution working directory. Hence it eventually gets resolved to ../../tmp/my.csproj

yes, I've also noticed that this error does show up when this specific criteria is meet, however, if the reference project IS INDEED in the same parent folder, the command works with no issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-CLI untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

5 participants