I'm a bit confused - the majority of .NET Core tutorials I have been reading have not mentioned "dotnet new sln" - they always just create the projects seperately with no solution file to link them together.
is "dotnet new sln" a new command?
when should I use this? what benefits do I gain from creating a sln file instead of just having project files? Is it mainly for opening in Visual studio? I use visual studio code for mac so may not be applicable.
I have googled "dotnet new sln" and the results are very minimal.
Yes. In version 1.0.1 of the dotnet command line interface, there is a
dotnet new sln
command. The command came with the change from project.json to csproj. If we rundotnet new --help
, we will see "Solution File" as one of the templates.Two times to use a solution file are:
One of the benefits that do not require Visual Studio is the management of multiple projects as a single unit.
For instance, on a Mac with VS Code, we can use the
dotnet
CLI to create a new solution, create a few projects, add those projects to the solution, restore the solution, and build the solution.The last command, which calls
dotnet build
, has the benefit of building all the projects that are in the solution. Without a solution, we would need to calldotnet build
on each project.There are no doubt other benefits which do not require the use of Visual Studio. I leave those to you to discover.