Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid parameter order when adding a project to sln using `dotnet sln add` should be validated

See original GitHub issue

General 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>

  <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.

  --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:

  1. Create new sln using dotnet new sln, example: dotnet new sln Solution50
  2. Create any kind of new project. For example: dotnet new mstest -n UnitTest01
  3. 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.



Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

sfoslundcommented, May 20, 2021

@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.

DavidKarlascommented, May 18, 2021

I transferred issue to dotnet/sdk because dotnet sln lives there.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found