I just created 10 queries with all the same columns and sort order. I then realized I missed a column and wanted to add another sort column to all those queries. I made the changes to one of the other 10 queries and thought there must be a way to do this without having to click a thousand times using the TFS UI.
The TFS SDK lets you update queries, so I just grab the select columns and the sort columns from the source query (the first one I modified) and then replaced those fields the destination queries. It’s pretty simple, but worth a quick post and will hopefully save you thousands of clicks as well.
You probably need to be a project admin for this to work. Ask your TFS admin to give you those perms.
1. Open a new console app.
2. Reference Microsoft.TeamFoundation.Client and Microsoft.TeamFoundation.WorkItemTracking.Client
3. Add the using statements:
4. Add this code to your main method
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("[url to your tfs server]"));
5. Replace [url to your tfs server] with the url to your tfs server, you can get this from your TFS admin.
6. Replace [your project name] with the name of your project.
7. Find the Guid of the source query. You can select the query in Team Explorer and hit F4. Copy the Guid in the Url field to the sourceGuid property in your code.
8. Find the Guid for all the queries you want to change and put those Guids in the destinationGuids collection.
9. Run the app.