You’ll need to use NuGet to install the Microsoft.TeamFoundationServer.ExtendedClient library before anything:

Then the following code:

Line 17 sets up the VssConnection which is used for multiple comman. Line 18 sets up the WorkItemTrackingClient (witClient). Line 20 retrieves the folder hierarchy; line 21 picks out the folder we specified. Line 22 sets up the returnValue for the procedure.

After that processing is fairly linear. We execute the query (and throw an exception if there’s no results). We pull down batchSize number of work items each time through the loop. Skip is used to track how many we’ve already snagged and should bypass on the next loop through.

Next up: pulling changesets based on their relationship to work items.