Task element of Target (MSBuild)
Creates and executes an instance of an MSBuild task. The element name is determined by the name of the task being created.
<Task Parameter1="Value1"... ParameterN="ValueN" ContinueOnError="WarnAndContinue/true/ErrorAndContinue/ErrorAndStop/false" Condition="'String A' == 'String B'" > <Output... /> </Task>
Attributes and elements
The following sections describe attributes, child elements, and parent elements.
||Optional attribute. Condition to be evaluated. For more information, see Conditions.|
||Optional attribute. Can contain one of the following values:
- WarnAndContinue or true. When a task fails, subsequent tasks in the Target element and the build continue to execute, and all errors from the task are treated as warnings.
- ErrorAndContinue. When a task fails, subsequent tasks in the
- ErrorAndStop or false (default). When a task fails, the remaining tasks in the
Versions of the .NET Framework before 4.5 supported only the
For more information, see How to: Ignore errors in tasks.
||Required if the task class contains one or more properties labeled with the
A user-defined task parameter that contains the parameter value as its value. There can be any number of parameters in the
|Output||Stores outputs from the task in the project file. There may be zero or more
|Target||Container element for MSBuild tasks.|
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 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
<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>
Submit and view feedback for