dotnet / dotnet/msbuild

MSB4006 Circular dependency error

Open
#12,144 1 comment 1 reaction 1 assignee Assigned to @Copilot View on GitHub
Priority:1 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

Recently I came across circular dependency error that should not be thrown.
[SimpleMultiProcTest.zip](https://github.com/user-attachments/files/21165160/SimpleMultiProcTest.zip)
here is a sample of 5 projects dependencies:
```mermaid
graph TD
ProjectA --> ProjectB
ProjectA --> ProjectC
ProjectC --> ProjectD
ProjectC --> ProjectE
```
When trying to build ProjectA there is _sometimes_ MSB4006 error

### Steps to Reproduce

1. try to build ProjectA.csproj a few times until you see the error
2. error:
```
dotnet build ProjectA.csproj
Restore complete (0,3s)
ProjectE failed with 1 error(s) (0,1s)
/usr/local/share/dotnet/sdk/9.0.301/Microsoft.Common.CurrentVersion.targets(2138,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "ResolveProjectReferences".
ProjectD failed with 1 error(s) (0,1s)
/usr/local/share/dotnet/sdk/9.0.301/Microsoft.Common.CurrentVersion.targets(2138,5): error MSB4006: There is a circular dependency in the target dependency graph involving target "ResolveProjectReferences".

Build failed with 2 error(s) in 0,9s
```

### Expected Behavior

there shouldn't be any circular dependency error

### Actual Behavior

MSB4006 is thrown sometimes

### Analysis

_No response_

### Versions & Configurations

17.14.5.21107

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.