What is a NuGet package, and how do package versions and restore work?

.NET Framework & CLR Platform Basic 1–2 Yrs2–3 Yrs Conceptual 1 min read

Quick Answer

A NuGet package is a .nupkg archive containing compiled assemblies plus metadata, resolved from a feed (nuget.org, a private feed). <PackageReference Include="X" Version="8.0.1" /> in the .csproj declares a dependency; dotnet restore downloads it and its transitive dependencies, picking versions by the rules and any constraints.

A NuGet package is a zip of compiled DLLs and metadata that you pull from a feed like nuget.org. In the project file I add a PackageReference with a version, and dotnet restore downloads it plus everything it depends on. Versions are semantic — major, minor, patch. Transitive dependencies come automatically and NuGet resolves version conflicts, generally to the lowest version that satisfies all the constraints. For reproducible builds you commit a lock file, and for a big solution you use central package management so the version numbers live in one file instead of scattered across every csproj.

  • Versions follow SemVer: MAJOR.MINOR.PATCH (+ pre-release tags). A range like [8.0,9.0) is allowed but exact versions are the norm.
  • Transitive dependencies: your package's dependencies come along automatically; NuGet resolves conflicts to the lowest version that satisfies everyone (or nearest-wins).
  • packages.lock.json pins the full resolved graph for reproducible restores.
  • Central Package Management (Directory.Packages.props) declares versions once for a whole solution.