liveBook · Manning

NuGet

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

A NuGet package is a distributable package containing a .NET library or other reusable assets together with metadata and dependency information.

NuGet packages distribute .NET libraries and reusable assets with dependency information. Projects declare them in the .csproj file, and .NET tooling downloads and references them during restore. section 3.2.2 section 3.5

A typical NuGet workflow is:

  • Add a PackageReference to the project file, or run a command such as dotnet add package Newtonsoft.Json. section 3.5
  • Run dotnet restore to download declared dependencies and reference their files locally. section 3.2.2
  • Build or run the application; dotnet build restores automatically, and dotnet run restores and builds automatically. section 3.2.2

Adding an EF Core provider

An ASP.NET Core application can add SQLite support with PackageReference entries for Microsoft.EntityFrameworkCore.SQLite and Microsoft.EntityFrameworkCore.Design, both version 7.0.0. Restoring these packages prepares the application for building its EF Core data model. section 12.2.1

Listing 12.1 Installing EF Core in an ASP.NET Core application
<Project Sdk="Microsoft.NET.Sdk.Web">
 
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>                   #1
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
 
  <ItemGroup>
    <PackageReference                                           #2
      Include="Microsoft.EntityFrameworkCore.SQLite"            #2
      Version="7.0.0" />                                        #2
    <PackageReference                                           #3
      Include="Microsoft.EntityFrameworkCore.Design"            #3
      Version="7.0.0" >                                         #3
        <IncludeAssets>runtime; build; native; contentfiles;    #4
          Analyzers; buildtransitive</IncludeAssets>            #4
        <PrivateAssets>all</PrivateAssets>                      #4
    </PackageReference>
  </ItemGroup>

Inspect a complete .csproj example showing the target framework, PackageReference entries, versions, and private build-time assets. section 12.2.1

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

How deep it goes
Explains project declarations, restore, implicit CLI behavior, and package-version updates, but stops short of package-authoring internals.
Examples
Uses Newtonsoft.Json, EF Core SQLite, OpenAPI client-generation packages, and complete .csproj configurations.
What it assumes
Assumes a .NET project and introduces dependency restoration from the project file without requiring prior package-management detail.
What you can do after
Operate NuGet through .csproj PackageReference entries, dotnet restore, Visual Studio, and related .NET CLI commands.
How it connects
Connects NuGet with .NET CLI, .csproj files, PackageReference, EF Core, database providers, and OpenAPI client generation.

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.