当使用开源库,我们应该对编译源或二进制文件? [英] When using open source libraries, should we compile against the source or the binaries?

查看:214
本文介绍了当使用开源库,我们应该对编译源或二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在一个项目中使用开放源代码库(例如SharpPcap或FakeItEasy)应我们的源代码添加到解决方案或编译对DLL和对他们的解决方案目录?

When using an open source library in a project (for example SharpPcap or FakeItEasy) should we add the source code to the solution or compile against the DLLs and put them in a directory in the solution?

推荐答案

我觉得既不

以下是原因做不会把源代码:

Following are the reasons do NOT put the source code:


  • 开发者可能会不小心修改代码

  • 库通常如有变更

而以下是原因的 DO 包含DLL来解决:

And following are the reasons DO include DLLs to the solution:


  • 使部署更容易

  • 减少使用库

  • 的版本不兼容的几率降低缺少引用的几率

那么,怎么样?


  1. 添加一个新的类库一个独特的名字项目,比如 ClassLibrary1的,到解决方案

  1. add a new Class Library project with a unique name, say ClassLibrary1, to the solution

构建它的项目设置,配置输出路径应用程序输出路径

生成事件页,以下行添加到生成后事件命令行块:

in Build Events page, add the following line to Post-build event command line block:

del "$(TargetPath)"


  • 外部DLL复制到它的文件夹并将其添加到 ClassLibrary1的

    设置复制本地真正所有添加引用

    设置项目依赖关系其他项目给它,检查 ClassLibrary1的

    set Project Dependancies of other projects to it, check ClassLibrary1

    添加其他项目的引用,从DLL文件被放在 ClassLibrary1的

    add references of other projects, from the path the DLLs were put in ClassLibrary1

    设置复制本地到

    因此,项目 ClassLibrary1的是一个中央控制您的解决方案的外部库。每次你重建解决方案 ClassLibrary1的将最新的DLL文件添加到其参考应用程序输出文件夹,并删除它本身产生的名为 ClassLibrary1.DLL 的DLL。而在编译时或运行时将使用的DLL的相同版本的应用程序,你不需要做额外的部署或检查你释放你的应用程序每个部署每次。

    Thus, the project ClassLibrary1 be a central control of the external libraries of your solution. Everytime you Rebuild Solution, ClassLibrary1 copies the latest DLLs added to its References to the application output folder, and deletes the DLL it generated itself named ClassLibrary1.DLL. And the application at either compile time or runtime would use the same version of DLLs, you don't need to do extra deploying or check for each deployment everytime you release your application.

    这篇关于当使用开源库,我们应该对编译源或二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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