Migrating TFS Work Items from one project to another using Excel.

Hi All,

Its been very long since I have posted anything. Today I am gonna talk about migrating all your TFS Work Items from one project to another. Lets call the project where all your WIs are currently residing as Source Project and the project where you want to migrate your WIs as Target project. Your Target project can be in a totally different project collection or even in a different TFS server.

However TFS does not provide any way to migrate WIs between projects, there are few third party tools that helps in this scenario. I personally found using excel to Migrate very simple. I have used this technique to move work items from one project to another where target projects were in same collection, in different project collection and even different TFS server.

Okay so let’s get some work items moving to start with. The simplest scenario is, if both source and target projects use the same Process Template so that all your fields match.

If the templates don’t match then you’ll have to do some planning to understand how the fields match  (for example In Agile template Microsoft.VSTS.Scheduling.StoryPoints to Microsoft.VSTS.Scheduling.Effort in Scrum template) or fields that might be missing (eg. Microsoft.VSTS.Scheduling.CompletedWork or Microsoft.VSTS.Scheduling.OriginalEstimate).  If the fields are missing then you could consider adding them to the target process template, storing the information somewhere else or simply leave it behind.

 

Step 1: Create Query in Source Project

First you need to create a query in your source project that will result all the Work Items that you want move. You would also like to consider different columns for your query so you will have all the data you need.If you have any links between Work Items that you wish to preserve then it needs to be a Tree Query. At this point I will assume that you have planned this ahead and you know which WIs you want to migrate with what columns.You may need to play around with the query to get what you want.

MyTestQuery

Step 2: Copy and Save your Query to your Target Project

We have the query to export our data but now we want to move this query to our target project so we can import the data there.

Open the Source Project in Visual Studio Team Explorer and navigate to your newly created query.

MyScrumQuery

Right click on your query and select Edit Query. Now select File->Save As…

SaveQuery

We want to save our query to a file (*.wiq), somewhere in our local machine where we we can find it easily.  Open the file in a text editor of your choice (I like Notepad++).

Edit the Server URL if you are moving to a new Server, edit the Team Project Collection name if you are just moving to a new collection and edit the Team Project name in the .wiq file and save it again.

EditQuery

Now right click your query from Visual Studio and select “Open in Microsoft Excel” .
Now open your Target Project in Visual Studio and Select File->Open->File…
Navigate to your *.wiq query file.

Select Save As…

And select your new project as the target server. The query should now be available in the target Team Project.

TargetQuery

Now right click this new query in your target project and select “Open in Microsoft Excel“.

Copy the data from previously opened excel from source project query to the new excel opened from target project query. Modify any column or field needed if you are migrating to a project with different process template.

When we hit Publish on the Team menu, new Work Item IDs will be generated for us in the new project

Now we need to alter some things like the Work Item State.  The TFS Process Template will not allow us to create Work Items in a non-starting state so our items will be New or Active for example.  We need to filter on the Old States we want to edit.

Now we see only the items we need to change.  Change and then fill down the value in the State column and publish back to TFS.  Repeat the process for all the states returned in your query

You will also need to come back and do this for things like Area Path and Iteration Path if you haven’t already created them in your new project.  Just save this spreadsheet and you can refresh and publish from/to TFS anytime.

Now we have successfully migrated our Work Items from one project to another.

 

Advertisements

How to know the Process Template used to create a TFS project?

Once a TFS Team Project is created using a process template, there is no record of which process template was used to create the project for later reference. If someone create a project and left the team and another member wants to find out the process template used to create their project, then he will be in a bit of problem as he can’t directly check it any where.

The only possible way to find it is to check its work item types. For example, a project created using Scrum template will have a Backlog item of type “Product Backlog Item” as shown below.

ScrumProcess

A project created using Agile template will have a Backlog item of type “User Story” as show below.

AgileProcess

A project created using CMMI template will have a Backlog item of type “Requirement” as show below.

CMMI Process

By checking the work item type i.e. whether it is a Product Backlog Item or a User Story or a Requirement, we can determine the process template used to create the project as Scrum or Agile or CMMI respectively.