你如何在 Visual Studio 中的项目/解决方案之间共享代码?

你如何在 Visual Studio 中的项目/解决方案之间共享代码?

问题描述:

我有两个具有一些通用代码的解决方案,因此我想将其提取出来并在它们之间共享.此外,我希望能够独立发布该库,因为它可能对其他人有用.

I have two solutions which have some common code, so I'd like to extract it out and share it between them. Furthermore, I'd like to be able to release that library independently because it might be useful to others.

  • 使用 Visual Studio 2008 执行此操作的最佳方法是什么?
  • 一个项目是否存在于多个解决方案中?
  • 对于单独的一段代码,我有单独的解决方案吗?
  • 一个解决方案可以依赖另一个解决方案吗?

一个项目可以被多个解决方案引用.

A project can be referenced by multiple solutions.

将您的库或核心代码放入一个项目中,然后在两个解决方案中引用该项目.

Put your library or core code into one project, then reference that project in both solutions.