Invalid parameter order when adding a project to sln using `dotnet sln add` should be validated
See original GitHub issueGeneral Information
The dotnet sln add
should respect the order of parameter passed. If the order of the passed parameters are incorrect or invalid, it should display error and the command should not be executed successfully.
Current dotnet sln add
executed successfully when invalid order of parameters are passed.
Based on the current help from dotnet sln add -h
the parameters are ordered using this syntax:
dotnet sln <SLN_FILE> add [options] <PROJECT_PATH>
taken from:
D:\samplenet50>dotnet sln add -h
Usage: dotnet sln <SLN_FILE> add [options] <PROJECT_PATH>
Arguments:
<SLN_FILE> The solution file to operate on. If not specified, the command will search the current directory for one.
<PROJECT_PATH> The paths to the projects to add to the solution.
Options:
--in-root Place project in root of the solution, rather than creating a solution folder.
-s, --solution-folder The destination solution folder path to add the projects to.
-h, --help Show command line help.
SDK versions used
- 3.1 SDK: 3.1.403
- 5.0 SDK: 5.0.103, 5.0202, 5.0.203
Operating system
- Windows 10 1909
- Windows 10 2004
- Ubuntu 20 on WSL
Steps to reproduce
The steps are:
- Create new sln using
dotnet new sln
, example:dotnet new sln Solution50
- Create any kind of new project. For example:
dotnet new mstest -n UnitTest01
- Add the created new project into the previously created sln above, with invalid order of the parameters passed. Example:
dotnet sln add Solution50.sln UnitTest01\UnitTest01.csproj
Expected result: The project should not be added and it should display error with meaningful error message.
Actual result: The project added into the solution, but it still display error message.
Invalid project `D:\samplenet50\Solution50.sln`. The project file could not be loaded. Data at the root level is invalid. Line 2, position 1. D:\samplenet50\Solution50.sln.
Project `UnitTest01\UnitTest01.csproj` added to the solution.
Sample:
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
dotnet sln command - .NET CLI
The dotnet-sln command provides a convenient option to add, remove, and list projects in a solution file.
Read more >.net - How to add a Project (.csproj) to Solution (.sln) under ...
I am trying to add a csproj to a sln using dotnet sln command line. Adding the project is easily achievable using the...
Read more >How YOU can get started with .NET Core and C# in VS Code
It doesn't do much but it's valid C# code. Let's finish this section by adding to the solution: dotnet sln add library/library.csproj.
Read more >BuildConsole for Visual Studio
A path to an eVC 4.0 project (.vcp file). The BuildConsole command doesn't force you to include the .sln file as part of...
Read more >Creating and editing solution files with the .NET CLI
In this post, I show how to manage sln files with the .NET command line interface (CLI). See how to create sln files,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@eriawan thanks for filing an issue. This does seem to be a problem but I’m going to add it to our backlog as it is lower priority than other issues we have.
I transferred issue to dotnet/sdk because
dotnet sln
lives there.