35

I cannot find a way to create a new solution file using the dotnet core CLI commands described in https://learn.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-sln.

I ran the commands:

  • dotnet new web -n webtrain
  • dotnet new classlib -n core

after that, the projects were created correctly, but now I want to create a solution file to group them all, but I cannot find the right command to do that. Anyone knows how to do that?

Kelvin Ferreira
  • 535
  • 1
  • 5
  • 11
  • you linked to the documentation that shows the command dotnet sln, if that doesn't work for you then it means you probably don't have the latest sdk installed – Joe Audette Mar 21 '17 at 13:19
  • was an interpretation mistake. All the operations to create new things are into the `dotnet new ...` command. – Kelvin Ferreira Mar 21 '17 at 13:29

3 Answers3

68

looks like you use

dotnet new sln --name mysolution

https://learn.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-new

John
  • 29,788
  • 18
  • 89
  • 130
Joe Audette
  • 35,330
  • 11
  • 106
  • 99
  • thanks, was an interpretation mistake. I thought all `sln` operations would be in that `dotnet sln` commands. – Kelvin Ferreira Mar 21 '17 at 13:30
  • 20
    As of version 2.0.0, the tool adds a `.sln` automatically, so you should just do `dotnet new sln --name mysolution`. – 101100 Oct 28 '17 at 15:07
  • 1
    It adds the .sln extension regardless of whether you type it or not, so if you do type it, it adds it twice: Solution.sln.sln – Rhyous Aug 22 '22 at 21:24
4

AS I've seen it's a two step operation which consists of: 1 - Creating the Solution file with "dotnet new sln --name mysolution.sln" command in the folder you need and 2 - Add your csproj file to this solution with the command "dotnet sln yourSlnFileYouCreated.sln add PathToTheCsProjFile"

You can remove and add more projects to the same solution file if you want.

https://learn.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-new https://learn.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-sln.

3

first you have to create folder. this will be the solution name. then run this command inside that folder

dotnet new sln

this will create .sln file in that folder

balan kugan
  • 99
  • 1
  • 3