liveBook · Manning

Project

As explained in ASP.NET Core in Action, 3e

A project is a .NET unit of deployment containing the source files and configuration needed to build an application or library.

A .NET project is a unit of deployment: it builds into a .dll or an executable. Each separate application is a separate project, and a solution can hold multiple projects. For a first ASP.NET Core minimal API, a template creates the project and configures the basic pieces so you can get started quickly. section 3.2.1

A new web project has a few files worth finding first:

  • The .csproj file tells .NET tooling how to build the project, including its SDK, target framework, and NuGet package dependencies. section 3.4 section 3.5
  • Program.cs contains the code that configures and runs the application. appsettings.json and appsettings.Development.json provide runtime configuration. section 3.4 section 3.8
  • Properties/launchSettings.json controls how Visual Studio runs and debugs the app. The Dependencies and Connected Services nodes in Solution Explorer do not correspond to folders on disk. section 3.4

Most simple projects need few changes to their .csproj file. The SDK supplies build defaults, and TargetFramework selects the framework the app runs on. Source files are included in the build automatically rather than listed one by one. To add a NuGet dependency, add a PackageReference or use a command such as dotnet add package Newtonsoft.Json; restore downloads dependencies needed to build and run. section 3.5 section 3.8

Listing 3.2 The .csproj project file, showing SDK, target framework, and references
<Project Sdk="Microsoft.NET.Sdk.Web">               #1
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>       #2
    <Nullable>enable</Nullable>                     #3
    <ImplicitUsings>enable</ImplicitUsings>         #4
  </PropertyGroup>
</Project>

See a complete starter web-project file: the Web SDK, net7.0 target, nullable reference types, and implicit using statements fit in a short XML file. section 3.5

Project files also reflect what an application needs. An EF Core application adds its database provider as a NuGet package. A worker service uses the Worker SDK rather than the Web SDK and explicitly references hosting—and other packages it needs that a web app receives implicitly. Inspect package versions after Visual Studio generates an OpenAPI client: its generated references may need updating before the project builds. section 12.2.1 section 34.2.1 section 11.4.1

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains the starter folder layout and .csproj settings, then compares dependency needs across web and worker projects.
Examples
Uses a .NET 7 minimal API project, an EF Core package reference, and a worker-service project file.
What it assumes
Introduces projects and solutions from a first application rather than assuming familiarity with their layout.
What you can do after
Operate/configure a project by locating its key files and adjusting its target framework or package references.
How it connects
Links projects to solutions, .csproj files, target frameworks, NuGet packages, and package restore.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.