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.
oh wow, this is useful 🙂 we have to look for stuff in TFS all the time, I wonder how hard it would be to make a visual studio extension for this
Awesome; I love it! I will be using this plenty in the foreseeable future.
get cygwin and do it. I see no benefit to command line TFS?
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.
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.
This is what worked for me:
“C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\tf.exe” dir “$/My TFS Folder/MyFile.txt” /recursive /server:http://Server/PathToMyFiles
I’m using VS2012. I tried this and got:
The request was rejected by the server
HTTP code 400: Bad Request
Anyone know what I’m doing wrong?
I found installing TFS Power Tools works best.
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?
Brilliant…. but incredibly annoying that TFS still doesn’t provide this Search facility within VS2013 itself.
TF is garbage. CVS smokes this amateurish steaming pile.