Skip to content
Latchkey

NuGet "NU1108: Cycle detected" in CI

NuGet found a dependency cycle - package or project A depends on B which depends back on A. The resolver cannot produce a valid order and stops with NU1108.

What this error means

Restore fails with NU1108 showing the cycle (A → B → A). It is deterministic and tied to the dependency graph, commonly from a self-referential project reference or two mutually dependent packages.

dotnet restore output
error NU1108: Cycle detected.
 MyApp.Core -> MyApp.Data -> MyApp.Core (>= 1.0.0)

Common causes

Mutually dependent projects/packages

Two projects (or packages) reference each other, directly or through a chain, forming a cycle the resolver cannot order.

A package depends back on the consuming app

A locally produced package that lists the app as a dependency (or a bad version pin) creates a loop back to the start of the graph.

How to fix it

Break the cycle

  1. Trace the chain in the NU1108 message to find the back-reference.
  2. Extract the shared types into a third project both can depend on one-way.
  3. Remove the offending reference so the graph is acyclic.

Verify references are one-directional

Restructure so dependencies flow in a single direction (e.g. Data → Core, never Core → Data).

.csproj
<!-- MyApp.Data references Core; Core must NOT reference Data -->
<ProjectReference Include="..\MyApp.Core\MyApp.Core.csproj" />

How to prevent it

  • Keep project/package dependencies acyclic and one-directional.
  • Factor shared code into a leaf project that others depend on.
  • Review references after restructuring to avoid introducing loops.

Frequently asked questions

What causes ""NU1108: Cycle detected""?
Two projects (or packages) reference each other, directly or through a chain, forming a cycle the resolver cannot order.
How do I fix "NU1108: Cycle detected"?
Break the cycle

Related guides

References

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