getting associated changesets for work items

getting associated changesets for work items

During some of our internal processes, we port sets of approved bugs over from one branch to another. Since we're dogfooding Team Foundation, the bugs are Team Foundation work item id's and we need the changesets associated with those. You can easily open the work items inside VS, but if it's a dozen or more work items, that takes a bit of time just to get the associated changeset id's.

This is a beta3 sample (we're thinking about some ways of making this a little cleaner for RTM, but that's work in progress) that will take a list of work item id's and list out the associated changesets (if any) for those work items.

You may need to make your browser window wider if this code doesn't look right for you. Note that for simplicity it doesn't include error checking you would normally do (for instance, if you ask for a work item id that doesn't exist or you don't have access to, you'll get an exception, but this doesn't currently catch it) but it should get the point across. One of the things to take away from this is that we have a couple of concepts that are important here:

we have the concepts of artifacts (some of which are work items and changesets) inside Team Foundation. This is extensible as third parties can add their own artifacts.

we have a linking mechanism that holds associations (links) between artifacts.

I'll update this code once RTM is close if the API changes any.

Update: The linking support moved from the Microsoft.TeamFoundation.Server namespace in the Microsoft.TeamFoundation.dll library to Microsoft.TeamFoundation namespace in the Microsoft.TeamFoundation.Common.dll library - updates below (one using statement change), and a solution attached to make it easier for people to get this working for them.