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.
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
- Read the specific NU code and address it (upgrade the package, fix the version, target a compatible framework).
- Prefer fixing over suppressing so the signal stays useful.
- Re-run the build.
Scope the suppression narrowly if intentional
- Add only the specific code to
WarningsNotAsErrors(orNoWarn) rather than disabling all. - Document why the warning is accepted.
- Keep
TreatWarningsAsErrorson for everything else.
<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.