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

Add dotnet add|list|remove project commands for solution files

See original GitHub issue

The CLI needs to provide a way for users to manipulate the solution file (SLN file).

Below is a mini-spec of the command.

Usage

`dotnet add <project_or_solution> project <project>

Top level Verbs

  • add
  • list
  • remove

Arguments

  • <project_or_solution>
    • A project or a solution path
  • <project>
    • Path to the project file to include in the SLN file. Has to be a relative path.

Defaults

  • If the <project> is not present, we will try to see if there is a project in the current directory; if there is, it will be added, if not, an error is displayed
  • If the <project_or_solution> is not present, we will check the current directory for either a project file or a sln file.
    • If neither are found, an error is displayed
    • If more than one is found or if there is both sln and a project file present, an error is displayed prompting the user to specify which file the operation should work on.

Notes

  • This command adds a project to a solution if it works on an SLN file. In case a project file, it will add a <ProjectReference> to the project in question.
  • The command will make absolute paths of the project being added relative to the solution file/project being added. This is done to avoid messy breaks when moving machines.

Examples

  • dotnet add project "../path/to/project.csproj"
    • Add a project found at the specified path to the solution file
  • dotnet remove project "../path/to/project.csproj"
    • Remove a project found at the specified path to the solution file
  • dotnet list path/to/solution.sln project
    • List out all of the projects and configurations from the solution;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:10
  • Comments:19 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
TheSamsterZAcommented, Nov 22, 2016

@sayedihashimi

For website project, how important is that for you to be able to add on a mac? I don’t think we’ve considered this yet.

I think it’s important if only so that there is feature parity across platforms. We can do this in VS proper, so the expectation is that the dotnet sln command should be able to do it, too.

Add a way to set the default (startup) project(s): From the ASP.NET perspective the scenario is that I have a Web API service that my front end talks to. When I invoke dotnet run it would be good to start both.

This is exactly the scenario I was thinking of, so I am certain that having it in dotnet sln would be appreciated by many.

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 ...
Please try below code to add project to a solution from projects sub folder dotnet sln ../todo.sln add todo-app.csproj.
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 >
Add All Projects to Solution with dotnet CLI | Blog
This will recursively find .csproj files in any subfolder and will add them to the solution using the dotnet sln add command. With...
Read more >
How to Create a new Solution and Projects using dotnet CLI
I create a lot of samples, demos, open source projects, etc. and I like to use the fairly standard repository layout of having...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found