liveBook · Manning

Solution

As explained in Pro ASP.NET Core 7, Tenth Edition

A solution file is a .NET development file that groups multiple projects into a single build and management unit.

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

How Pro ASP.NET Core 7, Tenth Edition covers it

How deep it goes
Explains creation, project inclusion, naming, and opening, but does not detail the solution file format or build internals.
Examples
Uses PartyInvites, Testing, SportsSln, MySolution, and a command-line example adding web, data-model, and Blazor projects.
What it assumes
Assumes basic project and folder concepts while demonstrating solution creation and project association from the command line.
What you can do after
Create and populate a solution using dotnet new sln and dotnet sln add, then open it in a supported development environment.
How it connects
Connects solutions with projects, Visual Studio, Visual Studio Code, the .NET CLI, and global.json.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro ASP.NET Core 7, Tenth Edition. The section links point to the parts of the book it draws on.