Thursday, 28 March 2013

TFS 2012 Update work item template

Exporting work item definition fromTFS 2012

This guide is specific to TF2012 and VS2012.
All commands you will need to run from Developer Command Prompt for VS2012.

Get list all all items existing


First lets check what work items do we have in our project collection:

Command example

witadmin listwitd  /collection:http://TfsServer:8080/tfs/DefaultServices /p:ProjectName


where
  1. listwitd - list of work items
  2. /collection: select tfs server and your Team Project Collection
  3. /p:Project Name  Work item for project

Export the work item

Exporting template to xml file. This file you can modify using your Visual Studio


This one will fail
witadmin exportwitd  /collection:http://TfsServer:8080/tfs/DefaultServices /p:ProjectName /f:UserStory.xml /n:User Story

The reason for fail is user story has to be surrounded in double quotes
TF212000: Story is not a valid argument for this command. Type 'witadmin exportwitd /?' or 'witadmin help exportwitd' and press Enter for more information.


Update command as follows:

witadmin exportwitd  /collection:http://TfsServer:8080/tfs/DefaultServices /p:ProjectName /f:UserStory.xml /n:"User Story"

Update your work item template

When creating new fields into work item template make sure that you use name starting with unique prefix (for example: CompanyName.MyFieldName) and it is not only name of the field. This is to distinguish between custom fields and default build ones.


Validate your work item

To validate your updated template you can run command:
 
witadmin importwitd /collection:http://AdventureWorksServer:8080/tfs/DefaultCollection /f:WorkItemFileName.xml /p:ProjectName /v
 
The result should be for valid collection.

The work item type is valid.



Import work item to project

 To add new work item to tfs you can run command:

witadmin importwitd  /collection:http://TfsServer:8080/tfs/DefaultServices /f:WorkItemFile.xml
The work item type import has completed.

Destroy work  item

 Delete work item
itemwitadmin destroywitd /collection:http://TfsServer:8080/tfs/DefaultServices /p:ProjectName /n:WorkItemName

Are you sure you want to destroy the NewBug work item type as well as its 0 wo
rk item(s)?  This action is not recoverable. (Yes/No) y
The work item type was destroyed.

Article is written thanks to following resources

http://msdn.microsoft.com/en-us/library/dd312129.aspx