.NET › .NET CLI, SDK & Project Structure (csproj)
How do you add, remove, and list NuGet package references using the dotnet CLI?
IntermediateAnswer
`dotnet add package <PackageId>` adds a PackageReference to the .csproj (optionally with --version), `dotnet remove package <PackageId>` removes it, and `dotnet list package` shows all references, including outdated or vulnerable packages with the --outdated or --vulnerable flags.
dotnet add package Serilog.AspNetCore --version 8.0.0
dotnet list package --outdated
dotnet remove package Newtonsoft.JsonReal-world example A security audit runs `dotnet list package --vulnerable` across every project in a solution as part of a scheduled CI job to catch known CVEs in third-party dependencies before they reach production.