Export (0) Print
Expand All

UsingTask Element (MSBuild) 

Maps the task referenced in a Task element to the assembly that contains the task's implementation.


<UsingTask TaskName="TaskName"
    AssemblyName = "AssemblyName" 
    Condition="'String A'=='String B'" />

The following sections describe attributes, child elements, and parent elements.

Attributes

Attribute Description

AssemblyName

Either the AssemblyName or the AssemblyFile attribute is required.

The name of the assembly to load. The AssemblyName attribute accepts strong named assemblies although it is not required. Using this attribute is equivalent to loading an assembly via the Load method in the .NET Framework.

You cannot use this attribute if the AssemblyFile attribute is used.

AssemblyFile

Either the AssemblyName or the AssemblyFile attribute is required.

The file path to the assembly. This attribute accepts both full and relative paths. Relative paths are relative to the current project directory. Using this attribute is equivalent to loading an assembly via the LoadFrom method in the .NET Framework.

You cannot use this attribute if the AssemblyName attribute is used.

TaskName

Required attribute.

The name of the task to reference from an assembly. If ambiguities are possible, this attribute should always specify full namespaces. If there are ambiguities, MSBuild will choose an arbitrary match, which could produce unexpected results.

Condition

Optional attribute.

Condition to evaluate. For more information, see MSBuild Conditions.

Child Elements

None.

Parent Elements

Element Description

Project

Required root element of an MSBuild project file.

Environment variables, command line properties and project-level properties can be referenced anywhere inside of the UsingTask element as long as it appears inside of the project file, either explicitly or via an imported project file. For more information, see MSBuild Tasks.

NoteNote

Project-level properties have no meaning if the UsingTask element is coming from one of the .tasks files that are globally registered with the MSBuild engine. These properties are not global to MSBuild.

The following example shows how to use the UsingTask element with an AssemblyName attribute.

<UsingTask TaskName="Microsoft.Build.Tasks.Csc"
              AssemblyName="Microsoft.Build.Tasks" />

The following example shows how to use the UsingTask element with an AssemblyFile attribute.

<UsingTask TaskName="Email"
              AssemblyFile="c:\myTasks\myTask.dll" />

Community Additions

ADD
Show:
© 2014 Microsoft