| Severity | Error (fatal: the build stops) |
| Reported by | PostSharp |
| Message | Cannot sort the tasks because their dependencies form a cycle. Check the dependencies of the task types. |
Cause
PostSharp processes an assembly with a set of tasks, defined by task types: the built-in ones, and those of the plug-ins of PostSharp. Each task runs in a phase, and within a phase, PostSharp orders the tasks by their dependencies: when a task type depends on another one, the Position of the dependency says whether the other task runs before it, which is the default, or after it (After).
PostSharp reports PS0042 when these dependencies form a cycle between tasks of the same phase, for example when task A must run before task B and B before A, directly or through other tasks. The error is fatal: the build stops at this point.
This message requires task types whose dependencies form a cycle, which only a plug-in of PostSharp or a configuration file that defines task types can introduce, so no example can show it.
Resolution
- When the cycle comes from task types of your own, defined by a plug-in or by
TaskTypeelements of apostsharp.configor.psprojfile, remove one of the dependencies of the cycle, or change itsPosition. - Otherwise, make sure that every PostSharp package of the project has the same version, then restore the packages and rebuild: plug-ins of different versions can declare incompatible dependencies.
To see the tasks of the cycle, capture the trace with the ProjectLoader category of the PostSharpTrace MSBuild property, which lists them before the message:
dotnet build -p:PostSharpTrace=ProjectLoader -p:PostSharpUsePipeServer=False --no-incremental -v:detailed > trace.log
See Also
Other Resources
Well-Known MSBuild Properties
Configuring Projects Using postsharp.config