Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes the MSB4006 error code.
Message text
MSB4006: There is a circular dependency in the target dependency graph involving target 'value'. MSB4006: There is a circular dependency in the target dependency graph involving target 'value'. Since 'value' has 'value' dependence on 'value', the circular is 'value'.
Description
MSBuild has mechanisms for specifying which targets run before or after other targets, including BeforeTargets
and AfterTargets
attributes, and DependsOnTargets
attributes that specify that a target depends on the output of another target, so has to run after it. MSBuild uses this information to determine the target build order. See Target build order.
This error occurs when you have a circular dependency in the graph of target builds. There are two forms of the error, depending on whether MSBuild was able to identify the specific dependency issue, or not.
This error could also occur if you run the MSBuild task within a target, which creates an inner build, and the inner build depends on the outer build of the parent project.
Resolution
If the MSBuild error lists the targets that caused the dependency. If these are targets that you own and can modify, then review the AfterTargets
, BeforeTargets
, and DependsOnTargets
attributes on those targets and change something to avoid the circular dependency. However, it's important to change the targets in the right way. Refer to the target build order logic to understand how MSBuild determines the build order, and then analyze whether the dependencies are expressed correctly.
If the error message doesn't specify the specific targets involved in the circular dependency, try turning on verbose diagnostics (use the -v:diag
switch at the command line), or try using the binary logger and view it in the structured log viewer.
Applies to
All versions of MSBuild