在文件中查找:搜索 Team Foundation Server 中的所有代码
有没有办法在 TFS 中搜索每个文件的最新版本以查找特定字符串或正则表达式? 这可能是我从 Visual Source Safe 中错过的唯一一件事...
目前,我对整个代码库执行“获取最新”并使用 Windows 搜索,但是对于 75,000 个文件中超过 1GB 的代码,这会变得非常痛苦。
编辑:尝试了提到的强力工具,但“通配符搜索”选项似乎仅搜索文件名而不搜索内容。
更新:我们在现有的 MOSS(搜索服务器)安装中实现了自定义搜索选项。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
此加载项声称具有我相信您寻求的功能:
Team Foundation Sidekicks
This add-in claims to have the functionality that I believe you seek:
Team Foundation Sidekicks
目前还没有办法开箱即用地执行此操作,但有一个用户语音建议添加它:http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2037649-implement-indexed- 。
虽然我怀疑这是否像拨动开关那么简单,但如果每个看过这个问题的人都投票支持它,MS 可能会实施一些措施
更新:只需阅读 Brian Harry 的博客,其中显示此请求已在他们的雷达范围内,并且 Visual Studio 的在线版本对使用 git 作为 vcs 的搜索的支持有限:http: //blogs.msdn.com/b/visualstudioalm/archive/2015/02/13/announcing-limited-preview-for-visual-studio-online-code-search.aspx。 由此看来,我认为可以公平地说这只是时间问题...
更新 2: 现在有一个 Microsoft 提供的扩展,代码搜索,支持在代码和工作项中进行搜索。
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.
假设您有 Notepad++,一个经常被错过的功能是“在文件中查找”,该功能非常快并附带过滤器、正则表达式、替换和所有 N++ 功能。
Assuming you have Notepad++, an often-missed feature is 'Find in files', which is extremely fast and comes with filters, regular expressions, replace and all the N++ goodies.
对文件链接的搜索解释了如何查找文件。我确实必须仔细考虑建议才能使其正常工作。
在cd命令的情况下,我执行cd命令是因为我正在寻找tf.exe文件。 从该目录开始比添加整个路径更容易。 现在我了解了如何进行这项工作,我将在引号中使用绝对路径。
在 tf 搜索的情况下,我从服务器的根目录开始搜索
$/
并搜索以sql
结尾的所有文件,即*.sql< /代码>。 如果您不想从根目录开始,请改用
"$/myproject/*.sql"
。哦! 这并不能解决问题的文件搜索部分,但我的谷歌搜索将我带到这里在其他链接中查找文件。
This search for a file link explains how to find a file. I did have to muck around with the advice to make it work.
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.
In case of the tf search, I started at the root of the server with
$/
and I searched for all files that ended withsql
i.e.*.sql
. If you don't want to start at the root, then use"$/myproject/*.sql"
instead.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.
另一种解决方案是使用“ctrl+shift+F”。 您可以将搜索位置更改为本地目录而不是解决方案或项目。 这将取代桌面搜索,您仍然需要获取最新的代码,但它允许您留在 Visual Studio 中进行搜索。
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.
从 TFS 2015 开始,现在可以使用
Code Search
插件实现这一点。 https://marketplace.visualstudio.com/items?itemName=ms.vss-code-search< /a>搜索是通过 Web 界面完成的,不需要您将代码下载到本地计算机,这很好。
This is now possible as of TFS 2015 by using the
Code Search
plugin. https://marketplace.visualstudio.com/items?itemName=ms.vss-code-searchThe search is done via the web interface, and does not require you to download the code to your local machine which is nice.
我们已经为 Team Foundation Server 源代码控制(不是您提到的 SourceSafe)建立了一个解决方案,类似于 Grant 的建议; 预定的 TF Get、Search Server Express。 然而,用于 C# 文件(文本)的 IFilter 没有给出我们想要的结果,因此我们将源文件转换为 .htm 文件。 现在,我们可以向文件添加其他元数据,例如:
但是,我们更喜欢用于 TFS 源代码控制的协议处理程序,以及专用源代码 IFilter 以获得更有针对性的解决方案。
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:
We would however prefer a protocolhandler for TFS Source Control, and a dedicated source code IFilter for a much more targeted solution.
好的,
TFS2008 Power Tools 没有在文件中查找功能。 “在源代码管理中查找工具提供了通过项目的状态或使用通配符表达式在源代码管理中查找文件和文件夹的功能。”
CodePlex 上发布了具有此功能的 Windows 程序。 我刚刚安装并测试了它,它运行良好。
Okay,
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."
There is a Windows program with this functionality posted on CodePlex. I just installed and tested this and it works well.
如果安装 TFS 2008 PowerTools,您将在团队资源管理器右键菜单中获得“在源代码管理中查找”操作。
TFS2008 电动工具
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
就我而言,用 C# 编写一个小实用程序很有帮助。
对我有帮助的链接 -
http://pascallaurin42.blogspot.com /2012/05/tfs-queries-searching-in-all-files-of.html
如何使用 tfs api 列出团队项目的文件?
In my case, writing a small utility in C# helped.
Links that helped me -
http://pascallaurin42.blogspot.com/2012/05/tfs-queries-searching-in-all-files-of.html
How to list files of a team project using tfs api?
还有另一种替代解决方案,它似乎更有吸引力。
(Bissubscribe) 获取、删除、
每次签入时更新文件
发生。 所以这是一个网络服务
充当 TFS 上的侦听器
服务器,并更新/同步文件
以及搜索服务器上的文件夹。 - 这将显着提高准确性(实时搜索),并避免定期获取的一次性负载
搜索服务器上的索引搜索
为根文件夹
搜索结果
现在,完成上述所有设置后,您可以为客户端提供几个选项:
更新:
我确实走了这条路,而且效果很好。 只是想补充一下。
参考链接:
bissubscribe.exe
There is another alternative solution, that seems to be more attractive.
(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
indexed search on the Search server
for the root folder
search results
Now with all the above setup, you have a few options for the client:
Update:
I did go this route, and it has been working nicely. Just wanted to add to this.
Reference links:
bissubscribe.exe
Team Foundation Server 2015(本地)和 Visual Studio Team Services(云版本)包含对所有代码和工作项搜索的内置支持。
您可以执行简单的字符串搜索(如
foo
)、布尔运算(如foo OR bar
)或更复杂的特定于语言的操作(如class:WebRequest
)您可以在这里阅读更多相关信息:https://www .visualstudio.com/en-us/docs/search/overview
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.
You can do simple string searches like
foo
, boolean operations likefoo OR bar
or more complex language-specific things likeclass:WebRequest
You can read more about it here: https://www.visualstudio.com/en-us/docs/search/overview