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.
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
- Trace the chain in the NU1108 message to find the back-reference.
- Extract the shared types into a third project both can depend on one-way.
- 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).
<!-- 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.