Task Element (MSBuild)
Creates and executes an instance of an MSBuild task. The element name is determined by the name of the task being created.
Attributes and Elements
The following sections describe attributes, child elements, and parent elements.
Optional attribute. Condition to be evaluated. For more information, see MSBuild Conditions.
Optional attribute. Can contain one of the following values:
Versions of the .NET Framework before 4.5 supported only the true and false values.
For more information, see How to: Ignore Errors in Tasks.
Required if the task class contains one or more properties labeled with the [Required] attribute.
A user-defined task parameter that contains the parameter value as its value. There can be any number of parameters in the Task element, with each attribute mapping to a .NET property in the task class.
Stores outputs from the task in the project file. There may be zero or more Output elements in a task.
Container element for MSBuild tasks.
A Task element in an MSBuild project file creates an instance of a task, sets properties on it, and executes it. The Output element stores output parameters in properties or items to be used elsewhere in the project file.
If there are any OnError elements in the parent Target element of a task, they will still be evaluated if the task fails and ContinueOnError has a value of false. For more information on tasks, see MSBuild Tasks.
The following code example creates an instance of the Csc task class, sets six of the properties, and executes the task. After execution, the value of the OutputAssembly property of the object is placed into an item list named FinalAssemblyName.
<Target Name="Compile" DependsOnTarget="Resources" > <Csc Sources="@(CSFile)" TargetType="library" Resources="@(CompiledResources)" EmitDebugInformation="$(includeDebugInformation)" References="@(Reference)" DebugType="$(debuggingType)" > <Output TaskParameter="OutputAssembly" ItemName="FinalAssemblyName" /> </Csc> </Target>