Searching for a file in Team Foundation Server

Team Foundation Server is arguably one of the best source code control systems. Despite its feature abundance, it lacks a file search capability from the user interface. There are two ways to search for a file in TFS. One of them requires getting the latest from the particular branch and then searching for a file on the local machine. Not knowing which branch may contain the file renders this approach impractical. Downloading all the files located on TFS may take too much time and space. A better approach is to use the “tf” command. Here is an example:

C:\Program Files\Microsoft Visual Studio 9.0\VC>tf dir "$/MyTFSRoot/Branch1/SearchFileName.ext" /recursive /server:http://ServerName:8080

We opened the Visual Studio command prompt first.
The “tf” command is a TFS command.
The “dir” command will list all files whose name matches “SearchFileName.ext” and is located under “$MyTFSRoot/Branch1” folder and all its sub-folders on TFS server named “ServerName” using port “8080”.
It seems that TFS user interface still has to catch up functionality wise to its command line capabilities.

12 thoughts on “Searching for a file in Team Foundation Server

    • You can only use cygwin if you download every file in TFS to your local machine. At that point, you could just as well use Powershell or any of a myriad of search tools.

  1. You say to type tf dir “$/MyTFSRoot/Branch1/SearchFileName.ext”, but if I am doing that, then why do I even need to search? Obviously, I already know that SearchFileName.ext is loaced in $/MyTFSRoot/Branch1. What if I just have a file named SearchFileName.ext, and I need to know where in TFS it is?

    • The point is that the tf command will search all subfolders for the file. In this case all subfolders under $/MyTFSRoot/Branch1 will be searched for the file. If you do not know which branch your file is in, then start from the root.

  2. I’m using VS2012. I tried this and got:
    The request was rejected by the server
    Technical Information:
    HTTP code 400: Bad Request

    Anyone know what I’m doing wrong?

  3. The /recursive doesn’t seem to search folders that have the same name as the root.

    For example, if I’m looking for *.rdl

    It will find them in $/My Reports but it won’t even search $/My Reports/My Reports.

    Is there another switch or is this just a bug?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.