Skip to content

Updating NuGet Packages in C# Projects

For .NET 6/7/8 apps in VS Code:

dotnet list package --outdated
dotnet add package <PackageName>
dotnet restore
dotnet build

Alternatively, rather than adding the packages, I like to manually edit the version numbers in the .csproj file to those suggested by dotnet list package --outdated:

  1. Open your project file, e.g. MyApp.csproj.
  2. Find the <PackageReference> elements:
<ItemGroup>
  <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
  <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
  1. Update the Version attribute to the desired version.
  2. Save and then run:
dotnet restore

This is useful if you’re keeping versions pinned or managed in source control.

Use a VS Code extension

You can install the NuGet Package Manager extension for VS Code (by jmrog or doggy8088). It adds commands such as:

  • NuGet Package Manager: Add Package
  • NuGet Package Manager: Update Package
  • NuGet Package Manager: Remove Package

Use Ctrl + Shift + P → “NuGet Package Manager: Update Package”, then pick your project and package.

This is more interactive but essentially just runs the dotnet commands for you.