liveBook · Manning

Dotnet add package

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

dotnet add package is a .NET CLI command that adds a NuGet package reference to a project and restores the package.

dotnet add package adds a NuGet package reference to a .NET project, restores the package, and makes its namespace and classes available to source files. section 3.5

Use it from the project folder:

  • Run dotnet add package <packagename>. section 3.5
  • The command updates the .csproj file with a PackageReference and restores the package. section 3.5

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

How deep it goes
Explains the command, project-file change, and restore operation, but not package version selection or dependency conflicts.
Examples
Demonstrates installing Newtonsoft.Json and inspecting the resulting PackageReference in a net7.0 project file.
What it assumes
Assumes a .NET project and project-folder access while introducing NuGet and project-file dependency declarations.
What you can do after
Apply it via the .NET CLI to install a NuGet package and expose its library to project code.
How it connects
Connects NuGet packages with .csproj files, PackageReference, namespaces, and Visual Studio package management.

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.