Visual Studio:添加相同的项目或对不同解决方案的引用 [英] Visual Studio: Add same project or reference to different solutions

查看:113
本文介绍了Visual Studio:添加相同的项目或对不同解决方案的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置我的 Visual Studio 项目.我有一个通用项目(比如 SharedProj),它包含所有常量和通用类.SharedProj 将被其他两个解决方案(如 SolnA、SolnB)引用,但未来可能会更多.

I am trying to set up my Visual Studio projects. I have a generic project (say SharedProj) that has all the constants, common classes. SharedProj will be referenced by two other solutions (say SolnA, SolnB), but potential more in the future.

我能想到的有两种方法:

There are two ways I can think of:

  • 我可以将 SharedProj 添加到 SolnA 和 SolnB.
  • 或者我可以将 SharedProj.dll 添加到 SolnA 和 SolnB 中的引用.

由于这是我第一次研究引用其他项目/解决方案的解决方案,所以一种方式比另一种方式更受欢迎吗?

Since this is my first time working on a solution that references other projects/solutions, is one way preferred than the other?

顺便说一下,有没有什么简单的方法可以在 SharedProj 中重命名变量名称并更新对该变量的所有引用?就像我在项目中重命名一个变量的名称一样,有一个选项会显示将‘旧’重命名为‘新’",它会重命名所有内容.

By the way, is there any easy way to rename a variable name in SharedProj and updates all references to this variable? Like if I rename a variable's name within the project, there's an option that says "Rename 'old' to 'new'" which renames everything.

感谢您的帮助.

推荐答案

我处理这个问题的方式是为通用代码项目创建一个解决方案.构建库,然后将其发布到公共位置.您可能希望在此位置命名或以其他方式保留同一库的不同版本.然后我在需要它们的任何解决方案/项目中包含对已发布库的引用.由于我经常与其他开发人员共享这些和我的解决方案,我倾向于将它们保存在网络共享中并使用 UNC 路径引用它们,以避免在共享我的代码时出现与驱动器号相关的命名问题.

The way I handle this is to create a solution for just the common code project. Build the library, then publish it in a common location. You might want to name or otherwise keep different versions of the same library distinct in this location. Then I include a reference to the published libraries in any solutions/projects that need them. Since I often share these and my solutions with other developers, I tend to keep them on a network share and reference them using UNC paths to avoid naming issues with respect to drive letters when sharing my code.

在库中使用版本控制可以让您在时间轴上升级相关项目,而不是在发生更改或必须在多个位置维护代码时强迫您升级所有项目.请注意,使用公共代码的人越多,这一点就越重要.

Using versioning in your libraries allows you the ability to upgrade dependent projects on your timeline rather than forcing you to upgrade all whenever a change is made or having to maintain your code in several places. Note that the more people you have using the common code the more important that this is.

这篇关于Visual Studio:添加相同的项目或对不同解决方案的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆