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.
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.
dotnet nuget locals all --clear
dotnet restore --force
dotnet build -c ReleaseOrder cache and restore correctly
- Restore packages after restoring the NuGet cache, not before clearing it.
- Key the package cache on the lock file so it stays consistent with the assets file.
- On Windows, enable long-path support if path length truncated the restore.
How to prevent it
- Do not clear
~/.nuget/packagesbetween 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.