views:

8076

answers:

10

Is there a way to search the latest version of every file in TFS for a specific string or regex? This is probably the only thing I miss from Visual Source Safe...

Currently I perform a Get Latest on the entire codebase and use Windows Search, but this gets quite painful with over 1GB of code in 75,000 files.

EDIT: Tried the powertools mentioned, but the "Wildcard Search" option appears to only search filenames and not contents.

UPDATE: We have implemented a customised search option in an existing MOSS (Search Server) installation. Thanks for the help guys.

+5  A: 

If you install TFS 2008 PowerTools you will get a "Find in Source Control" action in the Team Explorer right click menu.

TFS2008 Power Tools

muerte
wcm
+4  A: 

@muerte it's funny that they're called 'power tools'. Some would say doing something like a rollback is 'basic functionality'. :-)

IainMH
well, you can certainly do a rollback manually, it's just not a one-click operation. Perhaps it should be..
Jeff Atwood
+14  A: 

TFS doesn't provide any mechanism for searching the contents of source control. Although all the source is stored in a SQL database, it's not in a format that the SQL FullText Search engine can index.

Your current solution of using Windows Search is about the best you can get.

Another option would be to setup a 'search server' that is dedicated to this job. You would have a scheduled task that does a "tf.exe get $/ /R" every few hours to keep a folder up to date. Then setup Windows Search, MOSS search, or CS2Search to index the contents.

CS2 - C# Code Search is actually really fast, and let's you do fancy queries like:

  • comment:foo
  • class:TestClass
  • etc..

Hope this helps.

Grant Holliday
+3  A: 

We have set up a solution for Team Foundation Server Source Control (not SourceSafe as you mention) similar to what Grant suggests; scheduled TF Get, Search Server Express. However the IFilter used for C# files (text) was not giving the results we wanted, so we convert source files to .htm files. We can now add additional meta-data to the files such as:

  • Author (we define it as the person that last checked in the file)
  • Color coding (on our todo-list)
  • Number of changes indicating potential design problems (on our todo-list)
  • Integrate with the VSTS IDE like Koders SmartSearch feature
  • etc.

We would however prefer a protocolhandler for TFS Source Control, and a dedicated source code IFilter for a much more targeted solution.

GertGregers
Any plans to open source the .htm conversion?
technomalogical
A: 

This add-in claims to have the functionality that I believe you seek:

Team Foundation Sidekicks

Paul G
Sorry I don't see where it offers to search inside files?
Mark Glorie
Atually I downloaded this plug-in set earlier and it only lets you search by author, label, date etc. but not inside older versions of files... :\
Sandor Davidhazi
+1  A: 

Another solution is to use "ctrl+shift+F". You can change the search location to a local directory rather than a solution or project. This will just take the place of the desktop search and you'll still need to get the latest code, but it will allow you to remain within Visual Studio to do your searching.

Todd
without indexing? ouch...
Mark Glorie
+1  A: 

Wow, I can't believe that MS decided to finally move to a SQL server based source control system, which has text indexing, but then decided to store source in a non searchable manner. Is this still true with TFS? (Jan 2, 2009)

There are a number of quarks with TFS - its one of those 'works in progress' that I feel need a bit more attention
Chance
+2  A: 

There is another alternative solution, that seems to be more attractive.

  1. Setup a search server - could be any windows machine/server
  2. Setup a TFS notification service* (Bissubscribe) to get, delete, update files everytime a checkin happens. So this is a web service that acts like a listener on the TFS server, and updates/syncs the files and folders on the Search server. - this will dramatically improve the accuracy (live search), and avoid the one-time load of making periodic gets
  3. Setup an indexing service/windows indexed search on the Search server for the root folder
  4. Expose a web service to return search results

Now with all the above setup, you have a few options for the client:

  1. Setup a web page to call the search service and format the results to show on the webpage - you can also integrate this webpage inside visual studio (through a macro or a add-in)
  2. Create a windows client interface(winforms/wpf) to call the search service and format the results and show them on the UI - you can also integrate this client tool inside visual studio via VSPackages or add-in

Update: I did go this route, and it has been working nicely. Just wanted to add to this.

Reference links:

  1. Use this tool instead of bissubscribe.exe
  2. Handling TFS events
  3. Team System Notifications
Vin
+1  A: 

Okay, 1 - TFS2008 Power Tools do not have a find-in-files function. "The Find in Source Control tools provide the ability to locate files and folders in source control by the item’s status or with a wildcard expression."

2 - There is a Windows program with this functionality posted on CodePlex -> http://tfssearchcode.codeplex.com/ I just installed and tested this and it works well.

toby

Thats a buggy tool. But it is working. Thansks!
Faiz
It's flaky and slow, but seem to do what it says on the tin
pm_2
A: 

http://tfssearchcode.codeplex.com/ tool didn't work for me. It crashes on connecting to my tfs server.