Recently, we upgraded our Team Foundation Server from 2008 to 2010 at work. Long overdue getting rid off some custom TFS Project templates, we were eager to use the new MSF for Agile 5.0 template. Now, we knew on beforehand that we couldn’t just upgrade existing team projects, so we had to come up with a migration plan.
First, we copied the Team Project Collection and “archived” a copy (NNN_Archive). Next, we created a dummy TFS Project with a Source Control root folder, and moved all the source code from all the existing projects into it. Next up, we created new team projects based on the aforementioned project template, and moved the source code back into the right folders in the VC tree.
Warning: We believed that doing it this way, we would preserve the VC history. Bummer! It did not! But since we had the archived TFS collection, we decided we didn’t want to revert to the backup, but just change to the other collection if we need to check the VC history in the future.
Next off, our architect and scrum masters wanted to migrate the work items from the archived collection to the new projects, so I had to brush off the dust of my TFS API skills and create a piece of throw-away code that would do the job.
Now, instead of just throwing away the code, I’m guessing that other people might need to do the same thing, so I’ve shared the source here.
You will have to tweak the source code to get it to work; the SOURCE_COLLECTION and TARGET_COLLECTION uri’s need to be set, as well as the TargetProjectName.
You will also have to tweak the WIQL query to return the work items you want to migrate – if you’re up for it, it shouldn’t be too hard to generalize the utility so that it would read the variables including the wiql from a configuration file.
Next up, you will have to adjust the MigrateWorkItem() method so that it copies the correct fields (optionally mapping to other field types in the new WI schema). The source code will copy attatchments – something that you also probably want to do. If you use the Links tab today, you will have to code up something that will lift over the links as well.
When you start the utility, you will be prompted with:
“Create [A]reas/Iterations or [M]igrate (Ctrl-C to quit)?:
The reason I did it this way, is that if you create the areas/iterations in the same pass as the work items, you will have to pause execution (Thread.Sleep) to ensure that the items has been commited to the TFS before the Work item is saved – IMO the two-pass strategy is cleaner.
Hope someone can reuse the code,