Find in Files: Search all code in Team Foundation Server

后端 未结 12 2208
情深已故
情深已故 2020-11-28 22:37

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...

相关标签:
12条回答
  • 2020-11-28 22:54

    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
    0 讨论(0)
  • 2020-11-28 22:56

    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.

    0 讨论(0)
  • 2020-11-28 22:57

    There is currently no way to do this out of the box, but there is a User Voice suggestion for adding it: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2037649-implement-indexed-full-text-search-of-work-items

    While I doubt it is as simple as flipping a switch, if everyone that has viewed this question voted for it, MS would probably implement something.

    Update: Just read Brian Harry's blog, which shows this request as being on their radar, and the Online version of Visual Studio has limited support for searching where git is used as the vcs: http://blogs.msdn.com/b/visualstudioalm/archive/2015/02/13/announcing-limited-preview-for-visual-studio-online-code-search.aspx. From this I think it's fair to say it is just a matter of time...

    Update 2: There is now a Microsoft provided extension,Code Search which enables searching in code as well as in work items.

    0 讨论(0)
  • 2020-11-28 23:03

    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.

    0 讨论(0)
  • 2020-11-28 23:04

    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. I just installed and tested this and it works well.

    0 讨论(0)
  • 2020-11-28 23:04

    This is now possible as of TFS 2015 by using the Code Search plugin. https://marketplace.visualstudio.com/items?itemName=ms.vss-code-search

    The search is done via the web interface, and does not require you to download the code to your local machine which is nice.

    0 讨论(0)
提交回复
热议问题