Skip to content
Latchkey

NuGet Warnings as Errors (NU1900-series) Failing CI

NuGet emits NU1900-series warnings (resolved-version bumps, framework fallbacks, vulnerability advisories). When TreatWarningsAsErrors is on, CI promotes these to errors and fails the build even though restore technically succeeded.

What this error means

Restore "succeeds" in terms of resolution but the build fails reporting a NU16xx/NU17xx/NU19xx warning as an error. Locally without TreatWarningsAsErrors it is just a warning, which is why it only bites in CI.

dotnet
error NU1701: Package 'Legacy.Lib 1.0.0' was restored using '.NETFramework,Version=v4.8'
instead of the project target framework '.NETCoreApp,Version=v8.0'.
This package may not be fully compatible with your project. [warning treated as error]

Common causes

TreatWarningsAsErrors promotes NuGet warnings

A global <TreatWarningsAsErrors>true</TreatWarningsAsErrors> turns restore warnings into build-breaking errors in CI.

A real advisory or fallback warning surfaced

A vulnerability advisory (NU1902/NU1903) or a framework fallback (NU1701) appeared and is now fatal under the strict setting.

How to fix it

Fix the underlying warning

  1. Read the specific NU code and address it (upgrade the package, fix the version, target a compatible framework).
  2. Prefer fixing over suppressing so the signal stays useful.
  3. Re-run the build.

Scope the suppression narrowly if intentional

  1. Add only the specific code to WarningsNotAsErrors (or NoWarn) rather than disabling all.
  2. Document why the warning is accepted.
  3. Keep TreatWarningsAsErrors on for everything else.
.csproj
<PropertyGroup>
  <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  <WarningsNotAsErrors>NU1701</WarningsNotAsErrors>
</PropertyGroup>

How to prevent it

  • Resolve NuGet warnings rather than blanket-suppressing them.
  • Keep suppressions scoped to specific codes with a documented reason.
  • Run a strict restore locally to catch promoted warnings before CI.

Frequently asked questions

What causes "NU1900-series warnings as errors"?
A global <TreatWarningsAsErrors>true</TreatWarningsAsErrors> turns restore warnings into build-breaking errors in CI.
How do I fix NU1900-series warnings as errors?
Fix the underlying warning

Related guides

References

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