64

I can't find a file in our source control of the TFS because it's simply a big mess. So I want to know if there is a way to search for files by their name?

I've heard of the Power Tool for TFS which enables search functionality but the problem is that it has to be installed and our sysadmin is currently not available. So does maybe a simple plugin exist?

Manuel Zelenka
  • 1,616
  • 2
  • 12
  • 26

4 Answers4

68

If you are using Visual Studio 2010

  • Right click on your collection or team project
  • Select 'Find in source control'
  • Then select 'status' or 'wildcard'
  • You can search for your files there

The following will list all the items in your repository without checking them out

tf Dir command

tf dir /recursive $/

you can pass in the item you are searching for also e.g.

tf dir /recursive $/*.cs

gets all the .cs files in all team projects

Note: depending on how big your source is, this could take sometime.

  • 2
    Thanks for your reply but this only works with TFS Power Tools installed and as I said at the moment our sysadmin isn't available and so I can't install them to get these features. But still thank you very much for trying to help! :) – Manuel Zelenka Nov 06 '12 at 14:10
  • 1
    @W1ese1 - the power toys go on you client machine not on the TFS Server - also the command line should work without the power toys. – DaveShaw Nov 06 '12 at 14:49
  • The problem with the power tools is that I have to work on a remote desktop and therefore I haven't got the rights to install anything. Seems like I have overseen the rest were you posted about the command line. I will check that out and if it works I'll mark your answer :) – Manuel Zelenka Nov 14 '12 at 13:08
  • Ok, I'd still need the power tools to be able to work with the tf command. But still thanks for your help. – Manuel Zelenka Nov 14 '12 at 13:21
  • 3
    tf.exe will be part of Visual Studio, TFPT.exe is the powertools executable. Make sure you launch it from a Visual Studio command Prompt. – Webplanet TFS Consulting Nov 14 '12 at 14:43
  • I don't know why i am seeing it in Visual studio 2008 while not in VS2010 – Kamran Shahid Jan 08 '14 at 06:58
  • 1
    I also had to use the /server command line option, like as specified at [http://devatheart.com/2010/10/24/searching-for-a-file-in-team-foundation-server/](http://devatheart.com/2010/10/24/searching-for-a-file-in-team-foundation-server/). – ALEXintlsos Oct 09 '15 at 17:47
  • Has this feature been added in VS 2015 IDE by default , or still we are dependent on power tools – Sundara Prabu Jan 07 '16 at 08:39
  • Please add the following note: Works on Local workspaces, not available for Server workspaces – Patrice Calvé Mar 17 '18 at 23:03
  • 1
    The "tf dir" command helped me. also, adding a "> filename.txt" to the end will allow you to export the results to a file for further analysis or import into excel etc. – Neville Mar 21 '18 at 01:21
  • 1
    The "find by wildcard" feature was removed from VS2017 (I used to use it a lot on VS2015) for some stupid reason. You are left only with commandline. – KurzedMetal Mar 01 '19 at 14:46
  • If you try to wildcard the filename ($/*.cs) you now get: TF402396: You cannot include wildcard characters in a team project name. – IanCaz Feb 19 '21 at 15:22
1

If you have created a workspace on your local, then you can search a file in your local to get the path.

krany
  • 19
  • 1
  • 2
    This works just fine as long as you don't have any cloaked dirs. – Chris O May 23 '16 at 18:14
  • 6
    if you have a TFS collection with hundreds of projects this solution is not viable. sure it works for finding a file in the current workspace, but the OP asked for searching a TFS collection. – Neville Mar 21 '18 at 01:20
1

If you're using Azure DevOps you can open the Azure Repos section in Azure DevOps for your project. There is a search input on this screen that allows you to search your code. You can find out more in Microsoft's documentation: https://learn.microsoft.com/en-us/azure/devops/project/search/code-search?view=azure-devops

Calum
  • 1,889
  • 2
  • 18
  • 36
1

Combining WebPlanet's answer and this https://devatheart.com/2010/10/24/searching-for-a-file-in-team-foundation-server/

I got the following to work when searching for a .rdl file on my TFS server.

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe" dir "$/*.rdl" /recursive /server:http://yourTFSserver
  • In my case tfs.exe was in the VS 2017 location.
  • http://yourTFSserver should be the path to the TFS server's web interface (including any port and path)
Matthew
  • 1,630
  • 1
  • 14
  • 19