如何查找哪些现有的.NET解决方案包含某个项目?

发布于 2024-09-05 09:56:46 字数 281 浏览 3 评论 0原文

我正在探索 C# 项目的文件夹结构,如下所示

    • 项目A
    • 项目B
    • 项目C
    • 项目D

.csproj 文件分散在同一文件夹中,有多个解决方案 (.sln) 文件。有没有一种快速的方法可以找到包含 ProjectD.csproj 的所有解决方案?我可以一一打开它们并查看它们包含的内容,但我想要一个功能,例如“查找包含该项目的所有解决方案”。

I am exploring a structure of folders with C# projects such as the following:

  • Projects
    • ProjectA
    • ProjectB
    • ProjectC
    • ProjectD

Scattered around in the same folders as the .csproj files, there are several solution (.sln) files. Is there a fast way to find all the solutions that contain ProjectD.csproj? I can open them one by one and see what they contain, but I would like a feature such as "find all the solutions containing this project".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

天冷不及心凉 2024-09-12 09:56:46

只需在扩展名为 .sln 的所有文件中进行在文件中查找搜索,并查找以单词“Project”开头的任何行。

我喜欢 TextPad,所以我用它来搜索,但还有很多其他工具,包括许多免费工具。

Just do a Find in Files search in all files with the extension .sln and look for any row beginning with the word "Project".

I like TextPad so I use that to search with but there are plenty of other tools including many free ones.

吻泪 2024-09-12 09:56:46

我认为这是不可能的,因为 VS 一次打开一个解决方案。但创建一个在 .sln 文件中搜索的简单脚本应该不难(总比没有好)。

I don't think it's possible since VS open one solution at a time. But it shouldn't be difficult to create a simple script that searches within .sln files (better than nothing).

煮茶煮酒煮时光 2024-09-12 09:56:46

安装 Cygwin 并运行 grep 解决方案文件。你永远不会回头...

Install Cygwin and run grep over the solution files. You'll never look back...

凉薄对峙 2024-09-12 09:56:46

上述两个解决方案(大卫·M的ho1's) 会起作用。

就我个人而言,我发现 grep 解决方案比尝试使用 MS 文件搜索实用程序更快,但第二个解决方案效果很好,特别是如果您不想安装额外的软件来完成您想做的事情。

Both the above two solutions (David M's and ho1's) will work.

Personally, I find the grep solution faster than trying to use the MS File Search utility, but the second one works well enough, especially if you don't want to install extra software to do what you want to do.

放赐 2024-09-12 09:56:46

我编写了一个 Perl 脚本来执行此操作(如果可能,使用 libxml2 来解析文件,因此它比 grep 稍微复杂一些)。它并不完美,但我在使用它的每个代码库中不断改进它。
我目前不会发布脚本。

更根本的改进是针对 Visual Studio API 进行编程。

在文件内查找文件名的更粗略的方法是在我的另一个 Perl 脚本中实现的, xref 。不幸的是,正确使用它可能会很棘手,因此您可能更喜欢手动使用 find 和 grep。

I wrote a Perl script to do it (using libxml2 to parse the files when possible, so it's slightly more sophisticated than grepping). It's not perfect, but I keep improving it with every code base I use it on.
I'm not publishing the script at this time.

A more fundamental improvement would be to program against the Visual Studio API instead.

The cruder approach of grepping for filenames inside files is implemented within another Perl script of mine, xref. Unfortunately, it can get tricky to use it correctly, so you may prefer to just use find and grep manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文