Skip to content
Latchkey

NuGet "error NU1403: Package content hash validation failed" in CI

With a lock file or RestorePackagesWithLockFile, NuGet verifies each downloaded package against the recorded hash. NU1403 means the hash did not match: the cached package is corrupt, a feed served a different artifact, or the lock file is stale.

What this error means

dotnet restore fails with "error NU1403: Package content hash validation failed for X.Y.Z. The package may have been tampered with or the local cache is corrupt."

dotnet
error NU1403: Package content hash validation failed for Newtonsoft.Json.13.0.3.
The package is different than the last restore.

Common causes

A corrupt or partial cached package

A truncated download left a bad package in the global packages folder, so its hash differs from the lock file.

A stale lock file after a feed change

The lock file records a hash from a different feed or a republished artifact, so the served package no longer matches.

How to fix it

Clear the cache and re-restore

  1. Clear NuGet's HTTP and global package caches.
  2. Re-run restore to fetch fresh, verified copies.
  3. If the mismatch persists for the same package, the lock file is stale, not the cache.
Terminal
dotnet nuget locals all --clear
dotnet restore --force

Regenerate the lock file

When the artifact legitimately changed, re-evaluate the lock so recorded hashes match the feed.

Terminal
dotnet restore --force-evaluate

How to prevent it

  • Restore from one trusted feed so artifacts and hashes stay stable.
  • Regenerate the lock file whenever a package version changes.
  • Cache the global packages folder consistently across runs.

Frequently asked questions

What causes ""error NU1403: ... content hash validation failed""?
A truncated download left a bad package in the global packages folder, so its hash differs from the lock file.
How do I fix "error NU1403: ... content hash validation failed"?
Clear the cache and re-restore

Related guides

References

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