将项目添加到 Visual Studio 解决方案时的问题

发布于 2024-10-26 10:07:53 字数 275 浏览 2 评论 0原文

我创建了一个全新的空白 Visual Studio 2010 解决方案,并向其中添加了一个现有的 C# 项目。我构建了解决方案并且编译正确。

但是当我转到解决方案文件夹时,我发现导入的 C# 项目实际上并不位于该文件夹中。看起来它只引用该项目,无论它在哪里。

这是故意的吗?我还应该担心这个吗?

如何创建物理导入,这意味着将项目复制到解决方案文件夹?

在此处输入图像描述

I created a brand new blank Visual Studio 2010 solution, and added an existing C# Project to it. I built the solution and it compiled correctly.

But when I go the solution folder, I see that the imported C# project is not physically in that folder. It seems it only references the project to wherever it is.

Is this intended? Should I even worry about this?

How can I create a physical import, meaning the project is copied to the solution folder?

enter image description here

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

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

发布评论

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

评论(3

萌辣 2024-11-02 10:07:53

如何创建物理导入,即将项目复制到解决方案文件夹?

如果要执行此操作,请将项目复制到解决方案(VS 外部),然后直接添加本地副本。

默认行为允许您在两个解决方案之间共享项目。这有时很有用(如果小心处理)。

How can I create a physical import, meaning the project is copied to the solution folder?

If you want to do this, copy the project to the solution (outside of VS), then add the local copy directly.

The default behavior allows you to share a project between two solutions. This is occasionally useful (if handled with care).

夜司空 2024-11-02 10:07:53

“如何创建物理导入?”

您不需要 - 您将一个项目添加解决方案,这将始终导致就地引用它。为了构建您的解决方案,您需要将现有项目复制或移动到所需的文件夹,创建任何所需的解决方案文件夹以匹配物理结构,然后添加现有项目根据需要。

另一种选择是添加新项目,然后从现有项目复制所有项目数据,但这在某些级别上很容易出现错误。

'How do I create a physical import?'

You don't - you're adding a project to the solution which will always result in referencing it in-place. In order to structure your solution you need to copy or move the existing project to the desired folder, created any desired Solution Folders to match the physical structure and then Add existing project as needs be.

The other alternative is to Add new project and then copy all of your project data over from the existing one but this will be prone to errors at some levels.

硪扪都還晓 2024-11-02 10:07:53

添加现有项目始终会引用原始项目。这在很多情况下都是有道理的。如果您想在多个解决方案中使用该项目,并且希望确保它们始终使用相同的版本,那么您可以选择仅引用编译的库或在每个解决方案中提供它。如果您确实在每个解决方案中都提供了它,那么风险就是您将在一个解决方案中对其进行一些修改,从而破坏其他解决方案。我很擅长做这件事!

如前所述,如果您想修改该项目并且不介意它是否与其他版本不同步,那么您需要将其复制到解决方案文件夹中,然后从那里添加它。

我使用的版本控制软件几乎迫使我这样做,因为它不喜欢不在解决方案树内的代码。

Adding an existing project always makes reference to the original. That makes sense in a lot of cases. If you want to use the project in a number of solutions and you want to make sure that they are always using the same version then you have the choice to either just reference the compiled library or have it available in each solution. If you do have it available in each solution then the risk is that you will make some mod of it in one solution that breaks the others. I am pretty good at doing this!

As mentioned already if you want to modify that project and don't mind if it gets out of sync with other versions of it then you need to copy it into your solution folder and then add it from there.

The version control software I use pretty much forces me to do that as it does not like code that is not located inside the solution tree.

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