How to include Multiple TFS Custom Task which is part of Single DLL


We define TFS Custom task in TFSBuild.Proj file as follows

<UsingTask TaskName="Task1" AssemblyFile="MySample.dll" />
<Target Name="AfterDropBuild">
    <Task1></Task1>
</Target>

UsingTask tag: is used to define task

TaskName attribute: is used to define task name, this name should be same as Class Name in our DLL & this class also should be of public type

TargetName tag: is used to define when to execute the custom task. In this case Custom task will be

executed “AfterDropBuild”after build drop event. To know more events http://msdn.microsoft.com/en-us/library/aa337604(v=vs.80).aspx

Now going back to our primary question, how to include multiple TFS Custom task are defined in single DLL.

If we do as below it will NOT WORK 

<UsingTask TaskName="Task1" AssemblyFile="MySample.dll" />
<Target Name="AfterDropBuild">
    <Task1></Task1>
</Target>

<UsingTask TaskName="Task2" AssemblyFile="MySample.dll" />
<Target Name="AfterDropBuild">
    <Task2></Task2>
</Target>

So make this working we need to define it as shown below

<UsingTask TaskName="Task1" AssemblyFile="MySample.dll" />
<UsingTask TaskName="Task2" AssemblyFile="MySample.dll" />
<Target Name="AfterDropBuild">
    <Task1></Task1>
    <Task2></Task2>
</Target>

Let's say if you want the Task2 to be executed first then Task1, So you need to modify as below 

<Target Name="AfterDropBuild">

    <Task2></Task2>
    <Task1></Task1>
</Target>

Happy coding. Hope this helps!

Ebook Download
View all
Learn
View all