PatchRail

.NET build failures — NU1605 / NETSDK / CS errors

Log signatures

error NU1605: Detected package downgrade
error NETSDK1045: The current .NET SDK does not support targeting
error CS0246: The type or namespace name could not be found
Version conflict detected
Build FAILED

What’s happening

The error code prefix tells you the layer, and that's the triage: NU____ (NuGet) — restore-time dependency problems; NU1605 package downgrade and Version conflict detected mean two projects in the solution pin different versions of one package. NETSDK____ — SDK/target-framework mismatch, the CI image's .NET SDK can't build the project's TargetFramework (e.g. project targets net9.0, image has SDK 8). CS____ (C# compiler) — a real compile error in your code. Xunit.Sdk / "Failed! - Failed:" — compilation succeeded; a test failed, a different problem entirely.

Fix playbook

  1. 1Grep the log for the first NU, NETSDK, or CS code and route accordingly.
  2. 2NETSDK errors: check global.json vs the SDK installed in CI (dotnet --list-sdks). Align one of them deliberately.
  3. 3NU conflicts: consolidate the package version across projects — central package management (Directory.Packages.props) makes the whole class structurally impossible.
  4. 4CS errors: ordinary compile fix; look up the code (they're well documented) and fix the narrowest site.
  5. 5Test failures: reproduce with dotnet test --filter "FullyQualifiedName~<TestName>" and treat as a test failure.

Prevention

  • Commit a global.json pinning the SDK major, and adopt central package management. Both convert "mysterious CI drift" into explicit, reviewable diffs.

Triage every red build, not just this one.

This page is one of 31 failure classes the open-source patchrail CLI matches from a raw log — locally, with secrets redacted first. If a log stumps it, open an issue; if it saves you a debugging morning, a star helps other maintainers find it.

★ Star on GitHubpipx install patchrail