.NET SDK "NETSDK1064: package X version Y was not found" in CI
NETSDK1064 fires at build time when the assets graph references a package/version that is not present in the restore output - it restored against a different graph than the build now expects, or the cached package directory is incomplete. It is a restore/build mismatch, not a missing-on-feed problem (that is NU1101/NU1102).
What this error means
The build fails with NETSDK1064 naming the package and version and suggesting it may have been deleted since restore. It often appears after a partial cache restore.
error NETSDK1064: Package Serilog, version 4.0.0 was not found. It might have been deleted
since NuGet restore. Otherwise, NuGet restore might have only partially completed.Common causes
Restore and build saw different package graphs
A version bump between the restore step and the build step, or a stale project.assets.json cached from a prior graph, leaves the build referencing a package the restore did not place.
The NuGet global-packages cache is incomplete
A partial or corrupted cache restore left the package directory missing the referenced version.
How to fix it
Force a clean, consistent restore
- Delete
objand re-rundotnet restore --forceso assets match the current graph. - Clear the NuGet cache if it may be partial:
dotnet nuget locals all --clear. - Rebuild so restore and build agree on versions.
dotnet nuget locals all --clear
dotnet restore --force
dotnet build --no-restore -c ReleaseHow to prevent it
- Run restore and build in the same job with the same package versions.
- Avoid caching
obj; cache only the global-packages folder.