Welcome to EMC Consulting Blogs Sign in | Join | Help

Crispin Parker's Blog

About Scrum for Team System and .Net development

Exporting TFS 2010 WIQL Queries

During the recent (and ongoing) development of the "Scrum for Team System" 2010 template (version 3.0 Beta for those counting) we needed to export team project queries. A new facility of Team Explorer 2010 is the ability to "Save As" when editing the query and chose the local file system. Pretty neat.

However, when you have a large suite of queries, this is very time consuming. You also have to strip out the server and project details from the resulting files before you can load them into a template. Being a developer at heart, the thought of repeating a single tedious action more that twice fills me with an inner dread. So I have written a simple command line utility that extracts all the queries from the specified project, maintaining the project query folder structure and stripping off any project specific content.

The "tfsQueryExport.exe" utility (attached below) requires 3 command parameters:

  • Usage:

    tfsQueryExport [tfs url] [project name] [output folder]
  • Example:

    tfsQueryExport "http://tfshost:8080/tfs/DefaultCollection" "Project 1" "c:\temp\Queries"

The output will be written to the specified output folder within a directory named after the project. 

Note: This utility makes use of the TFS 2010 Team Explorer assemblies, so you will needed TE installed before it will work.

Geeky Moment: I also needed to create the template query specification fragment in order to list the queries in our template, so I took a little time travel pill and wrote a batch file to traverse the exported query folder structure:

@ECHO OFF

cd.> Queries.txt

FOR /D %%D IN (.\*) DO (
    FOR /D %%X IN ("%%D\*") DO (
        (ECHO ^<QueryFolder name="%%X"^> >> Queries.txt)
        FOR /R . %%A IN ("%%X\*.wiq") DO (
            ECHO     ^<Query name="%%A" fileName="%%A"^> >> Queries.txt
        )
        (ECHO ^</QueryFolder^> >> Queries.txt)
    )
)


PAUSE

It's not perfect. You have to strip out the unwanted folder paths and file extensions. It only handles a single folder depth too, but I just fancied a little nostalgia! Please feel free to suggest some improvments, it's been a while since I wrote in DOS.

Crispin.

Published 10 July 2009 10:57 by crispin.parker
Attachment(s): tfsQueryExport.zip

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

TrackBack said:

July 28, 2009 15:30
 

Allen Feinberg said:

Looks like this tool doesn't work with TFS 2010 RTM:

Could not load type 'Microsoft.TeamFoundation.Client.TeamFoundationServerBase' from assembly 'Microsoft.TeamFoundation.Client, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

November 9, 2010 20:15
 

Daniel Pfulg said:

Is there an updated version of the tool available that is compiled against the release version? Or would it be possible to get the source code so that we can build it against to current version?

February 8, 2011 14:02
 

Allen Feinberg said:

Is there an updated version of this tool? I can't get it to work against 2010 RTM.

August 22, 2011 18:09

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

Powered by Community Server (Personal Edition), by Telligent Systems