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
