如何管理C#/ .NET中的版本依赖项? [英] How to manage version dependencies in a C#/.NET Project?

查看:998
本文介绍了如何管理C#/ .NET中的版本依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有项目A,这有各种各样的依赖关系,但是这个树看起来像这样:

 项目A 
=>项目B
=>项目C
=>项目D
=>项目C
=>项目E
=>项目C,v2

有没有办法使用Project E,因为它依赖于较新版本的Project即使项目的其余部分使用同一个图书馆的旧版本,C(dll)?



如果没有办法,或者会导致很多gnashing是否有一个前瞻性的解决方案,以防止在未来的项目中发生这种情况?

解决方案

从长期的解决方案如果这将在您的环境中工作,但是我们有多个依赖项目(从框架到依赖系统)。我们使用subversion并使用externals引用libary / source文件夹,以便所有的依赖项目引用相同的版本。



我们还有一些项目,我们带来依赖库这可能在编译时使用的是旧版本,而不是主引用应用程序包含的新的和向后兼容的共享库,在这种情况下,我们使用多版本解决方案使用配置条目。



我们实际上有我们的构建过程标记在其中(其中_BUILD_VERSION_被构建过程替换为当前版本号):

 < runtime> 
< assemblyBinding xmlns =urn:schemas-microsoft-com:asm.v1>
< dependentAssembly>
< assemblyIdentity name =Company.DependentAssemblypublicKeyToken =8510b56c219df72e/>
< bindingRedirect oldVersion =1.0.0.0-99.0.0.0newVersion =_ BUILD_VERSION _/>
< / dependentAssembly>

同一篇文章还有一种引用项目中相同程序集的多个版本副本的方法。 / p>

Suppose you have Project A, and this has various dll dependencies, but the tree looks something like this:

Project A 
    => Project B
        => Project C
    => Project D
        => Project C
    => Project E
        => Project C, v2

Is there a way to use Project E since it relies on a newer version of Project C (dll) even though the rest of the project is using an older version of that same library?

If there is not a way, or one that would cause much gnashing of teeth, is there a forward thinking solution to preventing this from happening on future projects?

解决方案

From a longer term solution, not sure if this will work in your environment, but we have multiple dependent projects (from frameworks to dependent systems) that we reference. We use subversion and use externals to reference the libary/source folders so that all the dependent projects reference the same version.

We also have some projects where we bring in dependent libraries that might have used an older version when it was compiled than the newer and backwards compatible shared library that the main referencing application has included, in which case we use the multiple version solution that uses the config entry.

We actually have our build process stamp in something like (where _BUILD_VERSION_ is replaced by the build process with the current build number):

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="Company.DependentAssembly" publicKeyToken="8510b56c219df72e"/>
            <bindingRedirect oldVersion="1.0.0.0-99.0.0.0" newVersion="_BUILD_VERSION_"/>
        </dependentAssembly>

The same article also has a way of referencing multiple version copies of the same assemblies in a project.

这篇关于如何管理C#/ .NET中的版本依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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