Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS 2010 and VS 2010 searching code in source control

This question is similar to: Find in Files: Search all code in Team Foundation Server However it was asked 4 years ago. I'm asking specifically about TFS 2010 with VS 2010.

Has Microsoft finally got around to adding back the searching of files for code snippets like they had way back in Visual Source Safe? If so, how to enable it and use it?

I've tried adding in Microsoft's Power Tools. While it has a search feature, the search is only for file names and ignores looking in the content in the files. :(

like image 682
DMCS Avatar asked Mar 26 '12 21:03

DMCS


People also ask

How do I get TFS source code?

Right-click your project or project suite in the Project Explorer and then click Source Control > Open From Team Foundation Server. Click Open From Team Foundation Server on the Source Control toolbar (if the toolbar is hidden, right-click the toolbar area and select Source Control).


5 Answers

I had the same problem and found this thread whilst looking for the solution. I then found that this functionality is available in a Visual Studio 2010 add-on called 'TFS Administrators Toolkit' in the Visual Studio Gallery. It seems to work!

MSDN links:

TFS Administrators Toolkit for VS 2010

TFS Administrators Toolkit for VS 2012

TFS Administrators Toolkit for VS 2013

like image 102
Craig Avatar answered Oct 07 '22 12:10

Craig


There's nothing inbuilt, and it would be difficult to do this at the database level due to the way that TFS stores files as deltas from previous versions.

The way I see it, there are two viable options, but both only work for the "tip" revision of the code. The easiest way is to do a "get" of all of your source, then use either the findstr command in a command window, or use something like Windows Grep to do the searching.

Alternatively, you could do what one of our more enterprising developers did, and use Lucene to index your code, then put a nice front-end around the results. We have this set up to get our MAIN branch and DEV branch on a regular basis, so we can get near-real-time search results.

There are also products like CAST which do impact analysis, and allow you to do some degree of searching, but at that point, you're looking at dropping some decent gold pieces to get the product.

like image 26
Robaticus Avatar answered Oct 07 '22 13:10

Robaticus


I'm not aware of anything that will do this.

The SourceSafe storage approach of 20 years ago was very basic, and the databases were limited to what we would now regard as "tiny" amounts of data. TFS stores compact differences between file versions, and there is no longer any "great big lump of text" that anyone can trivially search.

Any such tool would need to Get every version of every file to rebuild the original text to be searched, which would hammer your server for days or weeks. Add the testing overhead of producing a robust tool, and the chance of many people actually needing it, and it's not hard to see why it may never reach the top of the MS priority list - especially when they are still working on getting basic features like a usable pending checkins window, merge tools, and hopefully renaming of files(!) working for VS11.

It could be argued that with the automation model, or even just a console app calling tf.exe, writing a few lines of code yourself to iterate through all the versions of every file and apply a RegEx would be a relatively trivial task, if you really needed to apply such a search.

like image 38
Jason Williams Avatar answered Oct 07 '22 12:10

Jason Williams


In case you do not want to roll your own solution, I've worked with Krugle for TFS before (only testing and evaluating it) at a previous company and found it to be a very good solution.

like image 38
Edward Thomson Avatar answered Oct 07 '22 14:10

Edward Thomson


I know how I did it years ago using PVCS Version manager. I had a trigger on checkin and add archive. This queued up a worker process that would pull the source code and use the cygwin / unix command updatedb to create an index of all the files. The building of the database would go to a temp database and then swap out the read database super fast once it was built.

Then I had a website with a search function that called locatedb to pull back the names of files that contained the text.

TFS has subscriptions that can invoke webserivces.

like image 31
Christopher Painter Avatar answered Oct 07 '22 13:10

Christopher Painter