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

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

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

<p><strong>UPDATE</strong>: We have implemented a customised search option in an existing MOSS (Search Server) installation. </p>

[{'answer_id': 41399, 'author': 'markom', 'author_id': 1269, 'author_profile': 'https://Stackoverflow.com/users/1269', 'pm_score': 3, 'selected': False, 'text': '<p>If you install TFS 2008 PowerTools you will get a "Find in Source Control" action in the Team Explorer right click menu.</p>\n\n<p><a href="http://www.microsoft.com/en-us/download/details.aspx?id=15836" rel="nofollow noreferrer" title="TFS2008 Power Tools">TFS2008 Power Tools</a></p>\n'}, {'answer_id': 78966, 'author': 'granth', 'author_id': 11210, 'author_profile': 'https://Stackoverflow.com/users/11210', 'pm_score': 7, 'selected': True, 'text': '<p>Team Foundation Server 2015 (on-premises) and Visual Studio Team Services (cloud version) include built-in support for searching across all your code and work items.</p>\n\n<p>You can do simple string searches like <code>foo</code>, boolean operations like <code>foo OR bar</code> or more complex language-specific things like <code>class:WebRequest</code></p>\n\n<p><a href="https://i.stack.imgur.com/d0qL0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/d0qL0.png" alt="screenshot of code search filter syntax"></a></p>\n\n<p>You can read more about it here: <a href="https://www.visualstudio.com/en-us/docs/search/overview" rel="noreferrer">https://www.visualstudio.com/en-us/docs/search/overview</a></p>\n'}, {'answer_id': 110572, 'author': 'GertGregers', 'author_id': 19889, 'author_profile': 'https://Stackoverflow.com/users/19889', 'pm_score': 3, 'selected': False, 'text': '<p>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:</p>\n\n<ul>\n<li>Author (we define it as the person that last checked in the file)</li>\n<li>Color coding (on our todo-list)</li>\n<li>Number of changes indicating potential design problems (on our todo-list)</li>\n<li>Integrate with the VSTS IDE like Koders SmartSearch feature</li>\n<li>etc.</li>\n</ul>\n\n<p>We would however prefer a protocolhandler for TFS Source Control, and a dedicated source code IFilter for a much more targeted solution.</p>\n'}, {'answer_id': 210144, 'author': 'Paul G', 'author_id': 162, 'author_profile': 'https://Stackoverflow.com/users/162', 'pm_score': 0, 'selected': False, 'text': '<p>This add-in claims to have the functionality that I believe you seek:</p>\n\n<p><a href="http://www.attrice.info/cm/tfs/index.htm" rel="nofollow noreferrer">Team Foundation Sidekicks</a></p>\n'}, {'answer_id': 375970, 'author': 'Todd', 'author_id': 14030, 'author_profile': 'https://Stackoverflow.com/users/14030', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 722477, 'author': 'Vin', 'author_id': 1747, 'author_profile': 'https://Stackoverflow.com/users/1747', 'pm_score': 4, 'selected': False, 'text': '<p>There is another alternative solution, that seems to be more attractive.</p>\n\n<ol>\n<li>Setup a search server - could be any windows machine/server</li>\n<li>Setup a <strong>TFS notification service*</strong>\n(Bissubscribe) to get, delete,\nupdate files everytime a checkin\nhappens. So this is a web service that\nacts like a listener on the TFS\nserver, and updates/syncs the files\nand folders on the Search server. - <strong>this will dramatically improve the accuracy (live search), and avoid the one-time load of making periodic gets</strong></li>\n<li>Setup an indexing service/windows\nindexed search on the Search server\nfor the root folder</li>\n<li>Expose a web service to return\nsearch results</li>\n</ol>\n\n<p>Now with all the above setup, you have a few options for the client:</p>\n\n<ol>\n<li>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)</li>\n<li>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</li>\n</ol>\n\n<p><strong>Update</strong>:\nI did go this route, and it has been working nicely. Just wanted to add to this.</p>\n\n<p>Reference links:</p>\n\n<ol>\n<li><a href="http://www.codeplex.com/tfseventsubscription" rel="noreferrer">Use this tool instead of\nbissubscribe.exe</a></li>\n<li><a href="http://www.codeproject.com/KB/dotnet/HandlingTFSEvents.aspx" rel="noreferrer">Handling TFS events</a></li>\n<li><a href="http://blogs.microsoft.co.il/blogs/srlteam/archive/2006/11/10/Team-System-Notifications.aspx" rel="noreferrer">Team System Notifications</a></li>\n</ol>\n'}, {'answer_id': 988702, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>Okay,</p>\n\n<ol>\n<li><p>TFS2008 Power Tools do <strong>not</strong> 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 <strong>status</strong> or with a <strong>wildcard</strong> expression."</p></li>\n<li><p>There is a Windows program with this functionality posted on <a href="http://tfssearchcode.codeplex.com/" rel="nofollow noreferrer">CodePlex</a>. I just installed and tested this and it works well.</p></li>\n</ol>\n'}, {'answer_id': 23023410, 'author': 'Vijayanand Settin', 'author_id': 2125810, 'author_profile': 'https://Stackoverflow.com/users/2125810', 'pm_score': 4, 'selected': False, 'text': '<p>In my case, writing a small utility in C# helped.\nLinks that helped me -\n<a href="http://pascallaurin42.blogspot.com/2012/05/tfs-queries-searching-in-all-files-of.html" rel="noreferrer">http://pascallaurin42.blogspot.com/2012/05/tfs-queries-searching-in-all-files-of.html</a></p>\n\n<p><a href="https://stackoverflow.com/questions/469732/how-to-list-files-of-a-team-project-using-tfs-api">How to list files of a team project using tfs api?</a></p>\n\n<pre class="lang-cs prettyprint-override"><code>using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing Microsoft.TeamFoundation.Client;\nusing Microsoft.TeamFoundation.VersionControl.Client;\nusing Microsoft.TeamFoundation.Framework.Client;\nusing System.IO;\n\nnamespace TFSSearch\n{\nclass Program\n{\n    static string[] textPatterns = new[] { "void main(", "exception", "RegisterScript" };  //Text to search\n    static string[] filePatterns = new[] { "*.cs", "*.xml", "*.config", "*.asp", "*.aspx", "*.js", "*.htm", "*.html", \n                                           "*.vb", "*.asax", "*.ashx", "*.asmx", "*.ascx", "*.master", "*.svc"}; //file extensions\n\n    static void Main(string[] args)\n    {\n        try\n        {\n            var tfs = TfsTeamProjectCollectionFactory\n             .GetTeamProjectCollection(new Uri("http://{tfsserver}:8080/tfs/}")); // one some servers you also need to add collection path (if it not the default collection)\n\n            tfs.EnsureAuthenticated();\n\n            var versionControl = tfs.GetService&lt;VersionControlServer&gt;();\n\n\n            StreamWriter outputFile = new StreamWriter(@"C:\\Find.txt");\n            var allProjs = versionControl.GetAllTeamProjects(true);\n            foreach (var teamProj in allProjs)\n            {\n                foreach (var filePattern in filePatterns)\n                {\n                    var items = versionControl.GetItems(teamProj.ServerItem + "/" + filePattern, RecursionType.Full).Items\n                                .Where(i =&gt; !i.ServerItem.Contains("_ReSharper"));  //skipping resharper stuff\n                    foreach (var item in items)\n                    {\n                        List&lt;string&gt; lines = SearchInFile(item);\n                        if (lines.Count &gt; 0)\n                        {\n                            outputFile.WriteLine("FILE:" + item.ServerItem);\n                            outputFile.WriteLine(lines.Count.ToString() + " occurence(s) found.");\n                            outputFile.WriteLine();\n                        }\n                        foreach (string line in lines)\n                        {\n                            outputFile.WriteLine(line);\n                        }\n                        if (lines.Count &gt; 0)\n                        {\n                            outputFile.WriteLine();\n                        }\n                    }\n                }\n                outputFile.Flush();\n            }\n        }\n        catch (Exception e)\n        {\n            string ex = e.Message;\n            Console.WriteLine("!!EXCEPTION: " + e.Message);\n            Console.WriteLine("Continuing... ");\n        }\n        Console.WriteLine("========");\n        Console.Read();\n    }\n\n    // Define other methods and classes here\n    private static List&lt;string&gt; SearchInFile(Item file)\n    {\n        var result = new List&lt;string&gt;();\n\n        try\n        {\n            var stream = new StreamReader(file.DownloadFile(), Encoding.Default);\n\n            var line = stream.ReadLine();\n            var lineIndex = 0;\n\n            while (!stream.EndOfStream)\n            {\n                if (textPatterns.Any(p =&gt; line.IndexOf(p, StringComparison.OrdinalIgnoreCase) &gt;= 0))\n                    result.Add("=== Line " + lineIndex + ": " + line.Trim());\n\n                line = stream.ReadLine();\n                lineIndex++;\n            }\n        }\n        catch (Exception e)\n        {\n            string ex = e.Message;\n            Console.WriteLine("!!EXCEPTION: " + e.Message);\n            Console.WriteLine("Continuing... ");\n        }\n\n        return result;\n    }\n}\n}\n</code></pre>\n'}, {'answer_id': 32855930, 'author': 'jmoreno', 'author_id': 234954, 'author_profile': 'https://Stackoverflow.com/users/234954', 'pm_score': 1, 'selected': False, 'text': '<p>There is currently no way to do this out of the box, but there is a User Voice suggestion for adding it: <a href="http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2037649-implement-indexed-full-text-search-of-work-items" rel="nofollow noreferrer">http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2037649-implement-indexed-full-text-search-of-work-items</a> </p>\n\n<p>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.</p>\n\n<p>Update: Just read <a href="http://blogs.msdn.com/b/bharry/archive/2015/08/28/vs-online-tfs-feature-timeline-the-uservoice-version.aspx" rel="nofollow noreferrer">Brian Harry\'s blog</a>, 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: <a href="http://blogs.msdn.com/b/visualstudioalm/archive/2015/02/13/announcing-limited-preview-for-visual-studio-online-code-search.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/visualstudioalm/archive/2015/02/13/announcing-limited-preview-for-visual-studio-online-code-search.aspx</a>.  From this I think it\'s fair to say it is just a matter of time...</p>\n\n<p><strong>Update 2:</strong> There is now a Microsoft provided extension,<a href="https://marketplace.visualstudio.com/items?itemName=ms.vss-code-search" rel="nofollow noreferrer">Code Search</a> which enables searching in code as well as in work items.</p>\n'}, {'answer_id': 35325425, 'author': 'deadlydog', 'author_id': 602585, 'author_profile': 'https://Stackoverflow.com/users/602585', 'pm_score': 3, 'selected': False, 'text': '<p>This is now possible as of TFS 2015 by using the <code>Code Search</code> plugin. <a href="https://marketplace.visualstudio.com/items?itemName=ms.vss-code-search">https://marketplace.visualstudio.com/items?itemName=ms.vss-code-search</a></p>\n\n<p>The search is done via the web interface, and does not require you to download the code to your local machine which is nice.</p>\n'}, {'answer_id': 39671659, 'author': 'Greg', 'author_id': 3166138, 'author_profile': 'https://Stackoverflow.com/users/3166138', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://devatheart.com/2010/10/24/searching-for-a-file-in-team-foundation-server/" rel="nofollow" title="Search for a file">This search for a file link explains how to find a file.</a>  I did have to muck around with the advice to make it work.</p>\n\n<ol>\n<li>cd "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\Common7\\IDE"</li>\n<li>tf dir "$/*.sql" /recursive /server:<a href="http://mytfsserver:8080/tfs" rel="nofollow">http://mytfsserver:8080/tfs</a></li>\n</ol>\n\n<p>In the case of the cd command, I performed the cd command because I was looking for the tf.exe file.  It was easier to just start from that directory verses adding the whole path.  Now that I understand how to make this work, I\'d use the absolute path in quotes.</p>\n\n<p>In case of the tf search, I started at the root of the server with <code>$/</code> and I searched for all files that ended with <code>sql</code> i.e. <code>*.sql</code>.  If you don\'t want to start at the root, then use <code>"$/myproject/*.sql"</code> instead.</p>\n\n<p>Oh! This does not solve the search in file part of the question but my Google search brought me here to find files among other links.</p>\n'}, {'answer_id': 40399548, 'author': 'smirkingman', 'author_id': 338101, 'author_profile': 'https://Stackoverflow.com/users/338101', 'pm_score': 1, 'selected': False, 'text': '<p>Assuming you have <a href="https://notepad-plus-plus.org/" rel="nofollow noreferrer">Notepad++</a>, an often-missed feature is \'Find in files\', which is extremely fast and comes with filters, regular expressions, replace and all the N++ goodies.</p>\n'}]
['https://Stackoverflow.com/questions/41039', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/952/']