The other day I was asked if it was possible to find out if a specific string ever had occurred in the source files of a specific project. As this is not possible in TFS out of the box today I said that it could probably be done in a couple of hours if needed.
Creating a search function
Quite soon I was asked to put my money where my mouth was:) So I developed an Visual Studio Extension that, using the tfs api, would loop through each file and each file revision. As this would be a quite intense operation I placed it as a new feature in the TFS administrators Toolkit. I have some ideas to make it available as a standalone VS extension, extending source control explorer with a Find in File context menu, but at the moment it’s a TFS Administrators toolkit feature only.
Find in Files window
The result of my effort is the new Find in Files window in TFS Administrators Toolkit. It enables you to search for text in the content of source controlled files. Amongst its features is
• Search files in source control matching selected wildcards
• Option to search in History, searching through each file revision.
• Option to search case sensitive or not
• Option to search using Regular Expressions
Update!!! The Find in Files feature is availble in both VS 2010 and 2012. The 2012 version is updated with more features, as Search result prview, Source Control Explorer integration and more...
You can download the TFS Adminsitrators Toolkit from Visual Studio Gallery at
VS 2012 http://visualstudiogallery.msdn.microsoft.com/96a425aa-9ef0-4a92-b874-217d544a74bf
VS 2010 http://visualstudiogallery.msdn.microsoft.com/11f5e313-ced1-4713-9794-d7300c7d12e0
Wednesday, September 5, 2012
Find in Files : New feature of TFS Administrators Toolkit
Etiketter:
Admin,
TFS Administrators toolkit,
VS2010
Subscribe to:
Post Comments (Atom)
It would be nice to have option to search one file history. Eg I have line of code that is missing somewhere between 50+ changes and I need to find what was the last changeset it was present...
ReplyDeleteYou can do that by specifying the complete filname instead of a wildcard...
ReplyDeletePerhaps I can add a context menu and perhaps speed up the search if you only have a file selected.
Being able to actually view the files somehow directly from the results dialog would be very useful as well.
ReplyDeleteMaybe a preview pane that loads each one as you click on the individual result, with highlighted search matches?
Late update, Its done, hope you enjoy the new preview and open file features
DeleteThanks for your suggestions, actually I’ve been thinking about going in that direction also.
ReplyDeleteI created 2 work items based on you suggestions.
For the preview feature I’ve actually started to build something, stay tuned…
Subscription is not working - no subscriptions can be found...
ReplyDeleteIf I specify a path and wildcards VS is crashing
I deinstalled the extension
I have visual studio 2012 ultimate, connecting TFS 2010 server. After installing the extension http://visualstudiogallery.msdn.microsoft.com/96a425aa-9ef0-4a92-b874-217d544a74bf, I don't see the TFS adminstrator ToolKit option available in the context menu. Should I have admin rights?
ReplyDeleteHave you restarted VS?
DeleteCheck if you have the menu as in http://i1.visualstudiogallery.msdn.s-msft.com/11f5e313-ced1-4713-9794-d7300c7d12e0/image/file/85254/1/vs2012_tfs_admin_menu2.png
I just downloaded the toolkit for VS2012. I'm a fan!
ReplyDeleteWould you consider updating the FindInFiles to process multiple filename masks? We have a very large codebase and would like to search multiple file types without having to search gif, jpg, dll, etc. For instance, it would be extremely helpful to be able to put in a mask like this to search specific code file types:
*.vb;*.cs;*.aspx;*.ascx;*.asmx;*.xsd;*.dbml
Thanks,
Jim Thorn
HI Jim, and thank you for your kind words :)
DeleteActually my first reaction was that you could probably do it with the current version. The file mask is converted to a regexp and matched against the filename.
Unfortunately it looks like the current code prevent it from working by escaping the input. But I added the capability to handle multiple file masks seperated with ;
It’s changeset 103979 (http://tfsadmintoolkit.codeplex.com/SourceControl/changeset/103979
) if you want to build your own version and try it out.
I’ll try to push a new version as soon as I checked some other feedback…
Thank you for such a quick response! Looking forward to trying the new version. Keep up the good work.
DeleteJim
Just released a minor update, so now you can try it out in an official release :)
DeleteAlso, if you like it, consider reviewing it at the Visual Studio Gallery
Works great. Dramatically cut the time to search the code base by including only the file types I want to search.
DeleteThanks,
Jim
Thanks for the tool Mattis.
ReplyDeleteThe find file option is great but how does it search ?
Does it look into the users workspace or the server workspace?
Should I getlatest of the files?
Should I be mapped to a particular folder?
It doesn't search at all on your local disc! The tool fetches all files and file revisions directly from the server and performs the search directly in memory.
DeleteSo you don’t need to worry about what you got on your local file system, or fear that it will be changed by a search.
First of all, thank you so much for creating this tool. I was wondering if you would consider allowing a search on all source code within the entire collection rather than projects only?
ReplyDeletei have been trying to run this against numerous projects within a collection to search for references to a specific table. however, it frequently gets very far into the search and then errors out and restarts visual studio which causes me to lose the file locations already retrieved prior to the error. I'm not sure why it keeps getting errors, but it would be great if when it did, it simply displayed an error message instead of restarting vs and subsequently purging all of the search results in the process. Also, is there any way to export the search results to excel?
DeleteIf your using the VS 2012 extension, you can search on all code in a collection by right clicking on the root node/Collection name in Source Control Explorer and select Find In Files...
DeleteIm truly sorry if it restart your VS doing the search, are you using the 2012 or 2010 extension ? If your running 2010, can you try the same with the 2012 extension.
DeleteI will take a look if I got some error handling missing that could cause VS to restart.
For exporting to Excel, you can mark all rows in the search result table and copy and past it to Excel
hi, thanks for your response. i am using tfs 2010 and the 2010 extension. i just tried to download the 2012 extension from this link, but when i attempt to install, i get an error that says the extension manifest is invalid.
Deletehttp://visualstudiogallery.msdn.microsoft.com/96a425aa-9ef0-4a92-b874-217d544a74bf
Strange, have you installed VS 2012 or TeamExplorer 2012 ? You need to have a 2012 client installed to use the 2012 extension (but you can still connect to your old tfs server)
Deletei installed VS 2012 and your 2012 extension, and it worked great! thank you so much for publishing this.
DeleteThanks for this great tool. I have not figured out how I can restrict it to only search in certain parts of TFS instead on the whole archive. We have a structure like $ABC/main, $ABC/Branch/123, $ABC/Branch/345, ... I want to search only in the $ABC/main part and not in all the branches. How to do this?
ReplyDeleteThank you a lot for this great tool Matt. Is there any update of the tool (under VS 2010 & TFS 2008) or maybe a trick, to specify a teamproject branches/subdirectories. My teamproject contains a number of branches, and it takes a while to find a filecontent.
ReplyDeleteRegards
I just installed your extension (VS2010 version) but I can't find the Find in Files dialog anywhere in the Source Control Explorer, am I looking in the wrong place? In Source Control Explorer I'm right clicking on a folder, but no FindInFiles anywhere.
ReplyDeleteI would be nice if the Find In Files dialog was not modal that way I could continue to work while it searches.
ReplyDeleteI tried it, but I had a hard tim e getting it to a good experience, and didnt want to invest to much in it as Microsoft was working on a code search feature. I could take a swing at it again if I ever get an afternon free and dont have anything better to do :)
DeleteCan this be used to find a file that ONCE WAS in TFS but has been deleted? I know the name of the file, but don't remember where it was or when it existed. I would like to find the changeset where I deleted it within a collection.
ReplyDeleteAre there plans to update this for VS 2015 and TFS 2015?
ReplyDeleteI've installed TFS Administrators Toolkit in VS 2013 Professional. In the "Find In Files" section, how do I enter the project I would like to search? I cannot type in the "Search in" field and only one project (not the one I want) is displayed to choose from.
ReplyDeleteHi I have downloaded the installed for TFSADMINTOOLKIT 2010, 2013, 2012 and 2017 however I am not able to start using them there is no .exe file to have it included in TFS, please help how to get started using this tool.
ReplyDelete