My company has a common code library which consists of many class libary projects along with supporting test projects. Each class library project outputs a single binary, e.g. Company.Common.Serialization.dll. Since we own the compiled, tested binaries as well as the source code, there's debate as to whether our consuming applications should use binary or project references.
我的公司有一个公共代码库,它包含许多类库项目以及支持测试项目。每个类库项目输出一个二进制文件,例如Company.Common.Serialization.dll。由于我们拥有经过编译,测试的二进制文件以及源代码,因此我们的消费应用程序是否应该使用二进制或项目引用存在争议。
Some arguments in favor of project references:
一些支持项目引用的论据:
- Project references would allow users to debug and view all solution code without the overhead of loading additional projects/solutions.
- Project references would assist in keeping up with common component changes committed to the source control system as changes would be easily identifiable without the active solution.
项目引用将允许用户调试和查看所有解决方案代码,而无需加载其他项目/解决方案。
项目参考将有助于跟上提交给源控制系统的常见组件更改,因为在没有活动解决方案的情况下可以轻松识别更改。
Some arguments in favor of binary references:
一些赞成二进制引用的论据:
- Binary references would simplify solutions and make for faster solution loading times.
- Binary references would allow developers to focus on new code rather than potentially being distracted by code which is already baked and proven stable.
- Binary references would force us to appropriately dogfood our stuff as we would be using the common library just as those outside of our organization would be required to do.
- Since a binary reference can't be debugged (stepped into), one would be forced to replicate and fix issues by extending the existing test projects rather than testing and fixing within the context of the consuming application alone.
- Binary references will ensure that concurrent development on the class library project will have no impact on the consuming application as a stable version of the binary will be referenced rather than an influx version. It would be the decision of the project lead whether or not to incorporate a newer release of the component if necessary.
二进制引用可简化解决方案并缩短解决方案加载时间。
二进制引用将允许开发人员专注于新代码,而不是可能被已经烘焙并证明稳定的代码分散注意力。
二进制引用会迫使我们适当地哄骗我们的东西,因为我们将使用公共库,就像我们组织之外的那些人需要做的那样。
由于无法调试二进制引用(步入),因此必须通过扩展现有的测试项目来强制复制和修复问题,而不是仅在消费应用程序的上下文中进行测试和修复。
二进制引用将确保类库项目上的并发开发不会对使用应用程序产生影响,因为将引用二进制文件的稳定版本而不是流入版本。如有必要,项目负责人是否决定是否合并更新版本的组件。
What is your policy/preference when it comes to using project or binary references?
在使用项目或二进制引用时,您的策略/偏好是什么?
6 个解决方案
#1
5
It sounds to me as though you've covered all the major points. We've had a similar discussion at work recently and we're not quite decided yet.
听起来好像你已经涵盖了所有要点。我们最近在工作中进行了类似的讨论,但我们尚未做出决定。
However, one thing we've looked into is to reference the binary files, to gain all the advantages you note, but have the binaries built by a common build system where the source code is in a common location, accessible from all developer machines (at least if they're sitting on the network at work), so that any debugging can in fact dive into library code, if necessary.
但是,我们研究的一件事是引用二进制文件,以获得您注意到的所有优势,但是具有由公共构建系统构建的二进制文件,其中源代码位于公共位置,可从所有开发人员计算机访问(至少如果他们在工作中坐在网络上,那么任何调试实际上都可以在必要时深入到库代码中。
However, on the same note, we've also tagged a lot of the base classes with appropriate attributes in order to make the debugger skip them completely, because any debugging you do in your own classes (at the level you're developing) would only be vastly outsized by code from the base libraries. This way when you hit the Step Into debugging shortcut key on a library class, you resurface into the next piece of code at your current level, instead of having to wade through tons of library code.
但是,在同一个注释中,我们还使用适当的属性标记了许多基类,以使调试器完全跳过它们,因为您在自己的类中进行的任何调试(在您正在开发的级别)都会只有基础库中的代码才能大大超出。这样,当您点击库类的Step Into调试快捷键时,您将重新进入当前级别的下一段代码,而不必花费大量的库代码。
Basically, I definitely vote up (in SO terms) your comments about keeping proven library code out of sight for the normal developer.
基本上,我肯定会投票(以SO术语)关于保持经过验证的库代码对于普通开发人员不可见的评论。
Also, if I load the global solution file, that contains all the projects and basically, just everything, ReSharper 4 seems to have some kind of coronary problem, as Visual Studio practically comes to a stand-still.
此外,如果我加载全局解决方案文件,包含所有项目,基本上,只是一切,ReSharper 4似乎有某种冠状动脉问题,因为Visual Studio实际上是停滞不前。
#2
2
In my opinion the greatest problem with using project references is that it does not provide consumers with a common baseline for their development. I am assuming that the libraries are changing. If that's the case, building them and ensuring that they are versioned will give you an easily reproducible environment.
在我看来,使用项目引用的最大问题是它没有为消费者提供开发的共同基线。我假设图书馆正在改变。如果是这种情况,构建它们并确保它们的版本化将为您提供一个易于重现的环境。
Not doing this will mean that your code will mysteriously break when the referenced project changes. But only on some machines.
不这样做意味着当引用的项目发生变化时,您的代码会神秘地破坏。但只在某些机器上。
#3
2
I tend to treat common libraries like this as 3rd-party resources. This allows the library to have it's own build processes, QA testing, etc. When QA (or whomever) "blesses" a release of the library, it's copied to a central location available to all developers. It's then up to each project to decide which version of the library to consume by copying the binaries to a project folder and using binary references in the projects.
我倾向于将像这样的公共库视为第三方资源。这允许库拥有自己的构建过程,QA测试等。当QA(或任何人)“祝福”库的版本时,它被复制到所有开发人员可用的中心位置。然后由每个项目决定使用哪个版本的库,方法是将二进制文件复制到项目文件夹并在项目中使用二进制引用。
One thing that is important is to create debug symbol (pdb) files with each build of the library and make those available as well. The other option is to actually create a local symbol store on your network and have each developer add that symbol store to their VS configuration. This would allow you to debug through the code and still have the benefits of usinng binary references.
有一件重要的事情是使用库的每个版本创建调试符号(pdb)文件,并使这些文件也可用。另一种选择是在网络上实际创建本地符号存储,并让每个开发人员将该符号存储添加到其VS配置中。这将允许您通过代码进行调试,并仍然具有使用二进制引用的好处。
As for the benefits you mention for project references, I don't agree with your second point. To me, it's important that the consuming projects explicitly know which version of the common library they are consuming and for them to take a deliberate step to upgrade that version. This is the best way to guarantee that you don't accidentally pick up changes to the library that haven't been completed or tested.
至于你提到的项目参考的好处,我不同意你的第二点。对我而言,消费项目明确知道他们正在使用哪个版本的公共库并让他们采取深思熟虑的步骤来升级该版本,这一点非常重要。这是保证您不会意外地获取尚未完成或测试的库更改的最佳方法。
#4
1
when you don't want it in your solution, or have potential to split your solution, send all library output to a common, bin directory and reference there.
如果您不想在解决方案中使用它,或者有可能拆分解决方案,请将所有库输出发送到公共bin目录并在那里引用。
I have done this in order to allow developers to open a tight solution that only has the Domain, tests and Web projects. Our win services, and silverlight stuff, and web control libraries are in seperate solutions that include the projects you need when looking at those, but nant can build it all.
我这样做是为了让开发人员能够打开一个只有域,测试和Web项目的紧凑解决方案。我们的win服务,silverlight和Web控件库都是单独的解决方案,包括您在查看这些项目时所需的项目,但是nant可以构建所有项目。
#5
1
I believe your question is actually about when projects go together in the same solution; the reason being that projects in the same solution should have project references to each other, and projects in different solutions should have binary references to each other.
我相信你的问题实际上是关于什么时候项目在同一个解决方案中合并;原因是同一解决方案中的项目应该具有彼此的项目引用,并且不同解决方案中的项目应该具有彼此的二进制引用。
I tend to think solutions should contain projects that are developed closely together. Such as your API assemblies and your implementations of those APIs.
我倾向于认为解决方案应该包含紧密结合在一起的项目。例如您的API程序集和这些API的实现。
Closeness is relative, however. A designer for an application, by definition, is closely related to the app, however you wouldn't want to have the designer and the application within the same solution (if they are at all complex, that is). You'd probably want to develop the designer against a branch of the program that is merged at intervals further spaced apart than the normal daily integration.
然而,亲密度是相对的。根据定义,应用程序的设计者与应用程序密切相关,但是您不希望将设计器和应用程序放在同一解决方案中(如果它们完全复杂,那就是)。您可能希望针对程序的一个分支开发设计器,该分支以比正常日常集成更远的间隔合并。
#6
0
I think that if the project is not part of the solution, you shouldn't include it there... but that's just my opinion
我认为,如果项目不是解决方案的一部分,你不应该把它包括在那里......但这只是我的意见
I separate it by concept in short
我简单地将它与概念分开
#1
5
It sounds to me as though you've covered all the major points. We've had a similar discussion at work recently and we're not quite decided yet.
听起来好像你已经涵盖了所有要点。我们最近在工作中进行了类似的讨论,但我们尚未做出决定。
However, one thing we've looked into is to reference the binary files, to gain all the advantages you note, but have the binaries built by a common build system where the source code is in a common location, accessible from all developer machines (at least if they're sitting on the network at work), so that any debugging can in fact dive into library code, if necessary.
但是,我们研究的一件事是引用二进制文件,以获得您注意到的所有优势,但是具有由公共构建系统构建的二进制文件,其中源代码位于公共位置,可从所有开发人员计算机访问(至少如果他们在工作中坐在网络上,那么任何调试实际上都可以在必要时深入到库代码中。
However, on the same note, we've also tagged a lot of the base classes with appropriate attributes in order to make the debugger skip them completely, because any debugging you do in your own classes (at the level you're developing) would only be vastly outsized by code from the base libraries. This way when you hit the Step Into debugging shortcut key on a library class, you resurface into the next piece of code at your current level, instead of having to wade through tons of library code.
但是,在同一个注释中,我们还使用适当的属性标记了许多基类,以使调试器完全跳过它们,因为您在自己的类中进行的任何调试(在您正在开发的级别)都会只有基础库中的代码才能大大超出。这样,当您点击库类的Step Into调试快捷键时,您将重新进入当前级别的下一段代码,而不必花费大量的库代码。
Basically, I definitely vote up (in SO terms) your comments about keeping proven library code out of sight for the normal developer.
基本上,我肯定会投票(以SO术语)关于保持经过验证的库代码对于普通开发人员不可见的评论。
Also, if I load the global solution file, that contains all the projects and basically, just everything, ReSharper 4 seems to have some kind of coronary problem, as Visual Studio practically comes to a stand-still.
此外,如果我加载全局解决方案文件,包含所有项目,基本上,只是一切,ReSharper 4似乎有某种冠状动脉问题,因为Visual Studio实际上是停滞不前。
#2
2
In my opinion the greatest problem with using project references is that it does not provide consumers with a common baseline for their development. I am assuming that the libraries are changing. If that's the case, building them and ensuring that they are versioned will give you an easily reproducible environment.
在我看来,使用项目引用的最大问题是它没有为消费者提供开发的共同基线。我假设图书馆正在改变。如果是这种情况,构建它们并确保它们的版本化将为您提供一个易于重现的环境。
Not doing this will mean that your code will mysteriously break when the referenced project changes. But only on some machines.
不这样做意味着当引用的项目发生变化时,您的代码会神秘地破坏。但只在某些机器上。
#3
2
I tend to treat common libraries like this as 3rd-party resources. This allows the library to have it's own build processes, QA testing, etc. When QA (or whomever) "blesses" a release of the library, it's copied to a central location available to all developers. It's then up to each project to decide which version of the library to consume by copying the binaries to a project folder and using binary references in the projects.
我倾向于将像这样的公共库视为第三方资源。这允许库拥有自己的构建过程,QA测试等。当QA(或任何人)“祝福”库的版本时,它被复制到所有开发人员可用的中心位置。然后由每个项目决定使用哪个版本的库,方法是将二进制文件复制到项目文件夹并在项目中使用二进制引用。
One thing that is important is to create debug symbol (pdb) files with each build of the library and make those available as well. The other option is to actually create a local symbol store on your network and have each developer add that symbol store to their VS configuration. This would allow you to debug through the code and still have the benefits of usinng binary references.
有一件重要的事情是使用库的每个版本创建调试符号(pdb)文件,并使这些文件也可用。另一种选择是在网络上实际创建本地符号存储,并让每个开发人员将该符号存储添加到其VS配置中。这将允许您通过代码进行调试,并仍然具有使用二进制引用的好处。
As for the benefits you mention for project references, I don't agree with your second point. To me, it's important that the consuming projects explicitly know which version of the common library they are consuming and for them to take a deliberate step to upgrade that version. This is the best way to guarantee that you don't accidentally pick up changes to the library that haven't been completed or tested.
至于你提到的项目参考的好处,我不同意你的第二点。对我而言,消费项目明确知道他们正在使用哪个版本的公共库并让他们采取深思熟虑的步骤来升级该版本,这一点非常重要。这是保证您不会意外地获取尚未完成或测试的库更改的最佳方法。
#4
1
when you don't want it in your solution, or have potential to split your solution, send all library output to a common, bin directory and reference there.
如果您不想在解决方案中使用它,或者有可能拆分解决方案,请将所有库输出发送到公共bin目录并在那里引用。
I have done this in order to allow developers to open a tight solution that only has the Domain, tests and Web projects. Our win services, and silverlight stuff, and web control libraries are in seperate solutions that include the projects you need when looking at those, but nant can build it all.
我这样做是为了让开发人员能够打开一个只有域,测试和Web项目的紧凑解决方案。我们的win服务,silverlight和Web控件库都是单独的解决方案,包括您在查看这些项目时所需的项目,但是nant可以构建所有项目。
#5
1
I believe your question is actually about when projects go together in the same solution; the reason being that projects in the same solution should have project references to each other, and projects in different solutions should have binary references to each other.
我相信你的问题实际上是关于什么时候项目在同一个解决方案中合并;原因是同一解决方案中的项目应该具有彼此的项目引用,并且不同解决方案中的项目应该具有彼此的二进制引用。
I tend to think solutions should contain projects that are developed closely together. Such as your API assemblies and your implementations of those APIs.
我倾向于认为解决方案应该包含紧密结合在一起的项目。例如您的API程序集和这些API的实现。
Closeness is relative, however. A designer for an application, by definition, is closely related to the app, however you wouldn't want to have the designer and the application within the same solution (if they are at all complex, that is). You'd probably want to develop the designer against a branch of the program that is merged at intervals further spaced apart than the normal daily integration.
然而,亲密度是相对的。根据定义,应用程序的设计者与应用程序密切相关,但是您不希望将设计器和应用程序放在同一解决方案中(如果它们完全复杂,那就是)。您可能希望针对程序的一个分支开发设计器,该分支以比正常日常集成更远的间隔合并。
#6
0
I think that if the project is not part of the solution, you shouldn't include it there... but that's just my opinion
我认为,如果项目不是解决方案的一部分,你不应该把它包括在那里......但这只是我的意见
I separate it by concept in short
我简单地将它与概念分开