A solution file is a .NET development file that groups multiple projects into one unit for opening and managing them together. Visual Studio displays the referenced projects in Solution Explorer, while the .NET CLI creates and populates the solution with commands. section 3.2.1 section 4.1.1
Create and use a solution with this practical workflow:
- Create a solution directory and a project directory beneath it, keeping their names either distinct or identical according to your preference. section 7.1 section 4.1.1
- Create the solution with dotnet new sln, then add projects with dotnet sln <solution> add <project>. section 4.1.1
- Open the .sln file in Visual Studio, or open the containing folder in Visual Studio Code. section 3.2.1 section 6.1.1
- Add additional projects later when the application grows, such as a data model or Blazor WebAssembly project. section 37.2.4
Create a solution and add a web project
These commands create a .NET 7 web project inside SportsSln/SportsStore, create the solution file, and add the project to it:\n\n dotnet new globaljson --sdk-version 7.0.100 --output SportsSln/SportsStore\n dotnet new web --no-https --output SportsSln/SportsStore --framework net7.0\n dotnet new sln -o SportsSln\n dotnet sln SportsSln add SportsSln/SportsStore section 7.1
Listing 37.7 Adding solution references
dotnet sln add ../DataModel ../BlazorWebAssembly
Use this compact command example when adding existing projects to a solution. section 37.2.4
