Skip to content
Latchkey

dotnet "NETSDK1064: Package ... was not found" in CI

The build’s assets file references a package version that is no longer in the global-packages folder - "it might have been deleted since NuGet restore. Otherwise, NuGet restore may have only partially completed." A stale or partial restore state.

What this error means

Build fails with NETSDK1064 naming a package and version that "was not found", typically after a cache was cleared between restore and build, or a restore that did not finish. A clean restore fixes it.

dotnet build output
error NETSDK1064: Package Newtonsoft.Json, version 13.0.3 was not found. It might
have been deleted since NuGet restore. Otherwise, NuGet restore may have only
partially completed, which might have been due to maximum path length restrictions.

Common causes

Global-packages folder cleared after restore

A cache step or cleanup removed the package from ~/.nuget/packages after the assets file was written, so build can no longer find it.

Restore only partially completed

An interrupted or path-length-limited restore left the assets file referencing packages that were never fully downloaded.

How to fix it

Restore clean and rebuild

Force a full re-restore so every referenced package is present before building.

Terminal
dotnet nuget locals all --clear
dotnet restore --force
dotnet build -c Release

Order cache and restore correctly

  1. Restore packages after restoring the NuGet cache, not before clearing it.
  2. Key the package cache on the lock file so it stays consistent with the assets file.
  3. On Windows, enable long-path support if path length truncated the restore.

How to prevent it

  • Do not clear ~/.nuget/packages between restore and build.
  • Key the NuGet cache on the lock file to keep packages and assets in sync.
  • Ensure restore completes fully before the build step runs.

Frequently asked questions

What causes ""NETSDK1064: Package ... was not found""?
A cache step or cleanup removed the package from ~/.nuget/packages after the assets file was written, so build can no longer find it.
How do I fix "NETSDK1064: Package ... was not found"?
Force a full re-restore so every referenced package is present before building.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card