21
votes

I cannot find a way to create a new solution file using the dotnet core CLI commands described in https://docs.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?

3
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
was an interpretation mistake. All the operations to create new things are into the dotnet new ... command. - Kelvin Ferreira

3 Answers

38
votes
3
votes

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://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-new https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-sln.

0
votes

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