NuGet "NU1605: Detected package downgrade" in CI
A dependency in the graph asks for a higher version of a package than your direct reference pins, so NuGet would have to downgrade it. NU1605 is an error (not a warning) when WarningsAsErrors or the SDK default treats it as one - the fix is to pin the direct reference up to the required version.
What this error means
Restore fails with NU1605 showing the downgrade chain: a direct (>= lower) against a transitive (>= higher). It reproduces deterministically from the resolved graph.
error NU1605: Detected package downgrade: System.Text.Json from 8.0.4 to 8.0.0.
MyApp -> Some.Library 2.1.0 -> System.Text.Json (>= 8.0.4)
MyApp -> System.Text.Json (>= 8.0.0)Common causes
A transitive dependency requires a higher version
A package you depend on pulls in a newer version of a shared package than your own direct reference pins, creating a downgrade across the graph.
An old direct pin was never bumped
A PackageReference was pinned to an older version long ago and never updated as transitive requirements moved forward.
How to fix it
Raise the direct reference to the required version
- Read the chain to find the highest version any path requires.
- Pin your direct
PackageReferenceat or above that version. - Re-run restore to confirm the downgrade is gone.
<PackageReference Include="System.Text.Json" Version="8.0.4" />Centralize the version under CPM
- Move the version into a single
PackageVersioninDirectory.Packages.props. - Remove inline versions from the projects.
- Restore so every project resolves the same, sufficiently-high version.
How to prevent it
- Bump direct references when transitive requirements move forward.
- Adopt central package management to avoid per-project drift.
- Trace the NU1605 chain to find the highest required version before pinning.