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

By Surya Prakash Nov 03, 2011
Here we define TFS Custom task in TFSBuild.Proj file.

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!

Surya Prakash

B.Tech graduate in CSE, having 5+ years of experience in .Net related Technologies & Microsoft Certified Professional.   My interests are Coding, Writing complex Queries [like d most], reading [technical ... Read more

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs