Skip to content

Guides

How to cache NuGet packages

dotnet restore downloads the same packages on every run.

4 min read

dotnet restore downloads the same packages on every run.

Why it happens

~/.nuget/packages is empty on a fresh runner.

How to fix it

  1. Cache ~/.nuget/packages keyed on the packages.lock.json files
  2. Restore with --locked-mode for reproducibility
  3. Enable the NuGet lock file if you do not already use one

Your next build could be twice as fast, at half the price

Start free. Migrating away is the same one line, and we publish that diff too.