| Severity | Error |
| Reported by | PostSharp |
| Message | Cannot load the task "<TaskName>": the type "<TypeName>" is not a task. |
Cause
PostSharp builds a project by running tasks, which plug-ins add. A plug-in, or a configuration file such as postsharp.config, declares its tasks with TaskType elements. The Implementation attribute of a TaskType element gives the assembly-qualified name of the class that implements the task, for example Contoso.Weaver.AuditTask, Contoso.Weaver.
When PostSharp adds the task to the project, it creates an instance of this class with its default constructor. PostSharp reports PS0049, and stops building the project, when the class exists and can be instantiated, but is not derived from the PostSharp.Sdk.Extensibility.Task class of the PostSharp SDK. <TaskName> is the Name attribute of the TaskType element, and <TypeName> is the full name of the class. This usually happens when the Implementation attribute names another class of the plug-in assembly, for example a helper class or an attribute, instead of the task.
PostSharp then also reports PS0014 for the same task, with the stack trace of the PS0049 message: you can ignore this second message.
A TaskType element in a postsharp.config file can cause this message, but the PS0014 message that follows it contains a stack trace with the paths of the machine, so no example can show it.
Resolution
- Make the
Implementationattribute of theTaskTypeelement give the full name of the class derived fromTask, with its namespace, followed by a comma and the name of the assembly. - When the
TaskTypeelement is in a configuration file of your source tree, such aspostsharp.config, and the project does not need the task, remove the element. - When the
TaskTypeelement comes from a plug-in that you do not develop, report the problem to the author of the plug-in. - To see which configuration files and assemblies PostSharp loads, build with the
PostSharpTraceMSBuild property set toProjectLoader, and a build log verbosity of at leastnormal. See Well-Known MSBuild Properties.
See Also
Other Resources
Configuration File Schema Reference
Configuring Projects Using postsharp.config
Well-Known MSBuild Properties