Skip to main content

Posts

Showing posts from August, 2008

Custom TFS Task to Change WorkItem State

I recently had to create a custom task to update the state all work items associated with a changeset were in. Here is the code I came up with to accomplish this. First we start of by creating a general class that includes a few properties. The properties will allow us to pass in variables to the task. LocalPath and BuildURI are variables which TFS build provides for you. I also included the using statements you need to have for this task. 1:using Microsoft.Build.Utilities; 2:using Microsoft.TeamFoundation.Client; 3:using Microsoft.TeamFoundation.VersionControl.Client; 4:using Microsoft.TeamFoundation.WorkItemTracking.Client; 5:using Microsoft.TeamFoundation.Build.Client; 6: 7: 8:namespace MyCustomStuff.TFS.Tasks 9: { 10:publicclass UpdateWorkItemStatus : Task 11: { 12:// A value for each one of these properties must be supplied in the XML build file. 13:// LocalPath and BUILDURI can use the MSBuild variables of $(TeamFoundationServerURL) and $(BuildURI) 1…