NuGet is the .NET package manager—libraries ship as versioned packages referenced in .csproj, similar to Maven Central for Java. Restore downloads dependencies into a local cache.
Adding packages
dotnet add package Newtonsoft.Json
dotnet restore
Pin versions in CI; audit transitive dependencies for security advisories.
PackageReference
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Important interview questions and answers
- Q: dotnet restore?
A: Downloads NuGet packages declared in project files before build. - Q: Transitive dependencies?
A: NuGet pulls dependent packages automatically—review lock files in teams.
Self-check
- What command adds a package to a project?
- Where do PackageReference entries live?
Pitfall: Pin package versions in CI—dotnet add package without version constraints can pull breaking updates on restore.
Interview prep
- What is NuGet?
The .NET package manager—restore downloads dependencies listed in the csproj to a local cache before build.
- PackageReference vs packages.config?
Modern SDK projects use
PackageReferencein the csproj; legacy projects used separate packages.config files.