添加dll参考与项目参考的影响 [英] Impact of adding dll reference vs project reference

查看:69
本文介绍了添加dll参考与项目参考的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对构建时间有影响吗?.Net解决方案中,我们有大约30个项目,并且它们共享的项目通过项目引用添加.我正在考虑改为使用dll参考,以查看是否有任何构建性能提升.有没有人有过类似经历的经验?请分享您的想法.

Is there any build time impact ? We have around 30 projects in our .Net solution and they shared projects are added by project reference. I am thinking to change to dll reference instead to see if there is any build performance gain. Did anyone have experience on similar lines ? Please share your thoughts.

推荐答案

是的,根据配置CI的方式,可能会产生巨大影响.

Yes, there is potentially a huge impact depending on how you have your CI set up.

此问题的解决方案是将应用程序的逻辑部分(数据访问,表示等)组合到单独的解决方案中,并将它们转换为NuGet程序包.我已经成功地结合了TFS构建,发行管理和NuGet来自动完成从预发行"到稳定"的NuGet软件包的连续交付.

The solution to this is to group logical sections of your application (data access, presentation, whatever else) into separate solutions and turn them into NuGet packages. I've had a lot of success combining TFS build, Release Management, and NuGet to automate the continuous delivery of NuGet packages from "prerelease" to "stable".

您也可以将其打包PDB文件以进行调试,并且使用NuGet还可以帮助在不同的项目之间共享代码.如果Project A使用的是Package X的1.2.3版本,但是您已经将Package X的Project B更新为了2.0.0版本,则Project A可以愉快地继续使用版本1.2.3.

You can have it package up PDB files as well for debugging purposes, and using NuGet also helps with sharing code between different disparate projects. If Project A is using version 1.2.3 of Package X, but you've updated Package X to version 2.0.0 for Project B, Project A can happily keep consuming version 1.2.3.

进行这样的拆分时要记住的一件事:

One thing to keep in mind when doing a split like this:

const 变量会在编译时在所有程序集中用文本值替换 .如果您在程序集A中更改了 const 值,而程序集B引用了 const 值,则如果不重新编译,则该值在程序集B中将不会更改.您可以通过使用 readonly 字段而不是 const 来避免这种情况.

const variables are replaced at compile time across all assemblies with the literal value. If you change a const value in Assembly A, and Assembly B references the const value, the value will not change in Assembly B if you don't recompile it. You can avoid that by using readonly fields instead of const.

这篇关于添加dll参考与项目参考的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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