dotnet / dotnet/msbuild

Circular dependency error should include more information.

Open
#3,181 9 comments 8 reactions 1 assignee Claimed by @haiyuzhu View on GitHub
Area: Debuggability Area: Engine triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

When this throws, the error is fairly inscrutable:

https://github.com/Microsoft/msbuild/blob/951b2f068956429acf8ad283034f1031bbcf80f0/src/Build/BackEnd/Components/RequestBuilder/TargetBuilder.cs#L702-L714

It just says

```
error MSB4006: There is a circular dependency in the target dependency graph involving target "PrepareProjectReferences".
```

That's not very easy to find and fix.

We could keep a list of parents so that we could say something like

```
There is a circular dependency in the target dependency graph involving target {targetSpecification.TargetName}. Target {parentTargetEntry} has a {buildReason} dependency on it, but it is depended upon by {string.Join("<-", listOfParents)}.
```

Maybe only at higher verbosities.

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.