Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
MSBuild Reference
 UsingTask Element (MSBuild)
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework General Reference
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 directory of the project or targets file where the UsingTask element is declared. 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 chooses 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 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" />
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker