Open sandboxFocusImprove this doc

PS0049: Implementation Type of a Task Is Not a Task

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 Implementation attribute of the TaskType element give the full name of the class derived from Task, with its namespace, followed by a comma and the name of the assembly.
  • When the TaskType element is in a configuration file of your source tree, such as postsharp.config, and the project does not need the task, remove the element.
  • When the TaskType element 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 PostSharpTrace MSBuild property set to ProjectLoader, and a build log verbosity of at least normal. See Well-Known MSBuild Properties.

See Also

Other Resources

Configuration File Schema Reference
Configuring Projects Using postsharp.config
Well-Known MSBuild Properties