重新添加丢失的项目,而无需将其重新添加到引用它的所有项目中

发布于 2024-09-06 06:04:25 字数 428 浏览 2 评论 0原文

假设您在将整个文件夹移动到本地的某个新位置后打开了一个 .NET 解决方案(我的解决方案是 VS 2010)。现在,该解决方案中引用的项目之一不存在,因此当您启动 VS 时,它自然会告诉您该项目丢失了,因此您会一如既往地在解决方案资源管理器中看到该项目呈灰色。

好吧,我无法重新添加该项目(为该项目所在的位置指定不同的路径),除非我删除丢失的项目引用,然后尝试将其重新添加回解决方案。

但是,如何在不丢失其他项目中引用该缺失项目的所有引用的情况下重新关联项目呢?这可能吗?否则,每次我重新添加那个丢失的项目时,我最终都必须浏览大约 8 个引用它的项目,并为每个项目重新引用它,这是乏味的。我想这是有道理的,因为每个项目都在旧路径上引用了那个丢失的项目,所以它也会在那里中断它,但是有没有一种更简单的方法可以重新关联项目和对该丢失项目的引用,而不必每次花费 10 分钟如果只是路径发生了变化,是否需要重新关联它?

Lets say you open a .NET solution (mine being VS 2010) after you just moved your entire folder to some new location locally. Now one of the projects that was being referenced in that solution is not there and so when you launch VS, it naturally tells you that the project is missing and therefore as always you see the project greyed out in Solution Explorer.

Ok, well I can't go re-add that project (specify a different path for where that project lives) unless I remove the missing project reference and then try to re-add it back to the solution.

But how can I reassociate a project without losing all references in other projects that were referencing that missing project? Is this possible? Otherwise every time I re-add that missing project, I end up having to go through about 8 projects of mine that are referencing it and re-reference it for each one of those projects which is tedious. I guess it makes sense since each project was referencing that missing project at that old path so it would break it there as well but is there an easier way to re-associate a project and references to that missing project without having to take 10 minutes every time to re-associate it all over the place if simply the path has changed?

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

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

发布评论

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

评论(3

姜生凉生 2024-09-13 06:04:25

您有两种解决方案:

  1. 移动丢失的项目,使其相对于其他项目位于与之前相同的位置。

  2. 将项目读取到引用它的所有解决方案。

我会选择前者 - 除非你有其他项目引用该项目。

如果您只是关闭解决方案而不保存,请移动丢失的项目,然后重新打开解决方案 Visual Studio 应该就能找到它。

You have two solutions:

  1. Move the missing project so that it's in the same location relative to the other projects as it was before.

  2. Readd the project to all the solutions that are referencing it.

I'd go with the former - unless you have other projects referencing that project.

If you just close the solution without saving, move the missing project and then re-open the solution Visual Studio should just find it.

〃安静 2024-09-13 06:04:25

在记事本中打开 .sln 文件,然后更改文件顶部附近的 Project 语句中的路径。无需更改 .csproj 文件中 元素中的路径,它们会自动更新。

Open the .sln file in Notepad and change the path in the Project statement near the top of the file. No need to change the path in the <ProjectReference> elements in the .csproj files, they'll get automatically updated.

神魇的王 2024-09-13 06:04:25

不确定是否有一些不错的 GUI 方法可以做到这一点,但使用具有 Find-In-Files/grep 功能的文本编辑器来搜索所有项目/解决方案文件中旧文件的所有实例可能会更容易手动替换它们而不是通过 GUI。

Not sure if there's some nice GUI way of doing it, but it might be easier to just use a text editor with Find-In-Files/grep ability to search for all instances of the old file in all project/solution files and then just replace them by hand rather than via the GUI.

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