Skip to content

Circular dependency error should include more information. #3181

Open

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Area: EngineIssues impacting the core execution of targets and tasks.triaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions