Thursday, May 17, 2012

How to retrieve all build definitions using Team Build API in TFS 2010

Team Foundation Server 2010 provides us with Team Foundation Server API to manage lots of items via code.  In this example we shall see how we can retrieve Build definitions for a given Team Project in a given Team Project Collection.

First you will have to add references to the following assemblies. Go to Project>Add Reference>Search for Microsoft.TeamFoundation and you will all the three assemblies required for our project.
The IBuildDefinition contains all the properties and methods related to a TF Build Definition. In the above code, we are also displaying ProcessParameters of the IBuildDefinition object. When you see it will show us an XML formatted string and in order to manipulate this string we have to parse the xml and then change those parameters. We can queue multiple builds in a single click if we want to. Moreover, if we want, then we can do some complex logic like triggering another build based upon a build's status. I haven't tried but it seems exciting to me. Leave your thoughts and comments below regarding the article.

No comments:

Post a Comment