NuGet 包依赖项 [英] NuGet Package Dependencies

查看:25
本文介绍了NuGet 包依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个包对某个其他库的每个依赖项,是否也需要解析和安装这些库?

Is it true that for every dependency that a package has on some other library, that those libraries need to be resolved and installed as well?

例如,我创建了一个使用 NLogPostsharpWindowsAzure.Storage 的包:

For example, I created a package which uses NLog, Postsharp and WindowsAzure.Storage:

我的软件包的客户现在是否也必须安装这些软件包?为什么不能在包中包含这些依赖 DLL?

Do clients of my package now have to install these packages as well? Why is it not possible to include these dependency DLLs within the package?

推荐答案

当消费者安装你的nuget包时,nuget也会自动解析并安装依赖包.

When a consumer installs your nuget package, nuget will automatically resolve and install the dependent packages as well.

可以在包,但不推荐.因为一种或另一种方式,他们必须引用他们需要使用您的包的 dll(在本例中为 NLogPostSharpWindowsAzure.Storage).最好让消费者自己控制安装的库.

It is possible to include the dlls within the package but it is not recommended. Because one way or another they will have to have references to the dlls they need to use your package( in this case NLog, PostSharp and WindowsAzure.Storage). Its better that the consumer have controll over what libraries are installed.

通过 nuget 获得依赖项的另一个好处是,消费者可能会决定安装较新版本的 WindowsAzure.Storage 库,当您没有将 dll 注入包中时,他可以轻松完成此操作.否则你可能会遇到一些混乱的程序集运行时错误.

Another benefit of having dependencies via nuget is that the consumer may decide to install a newer version of WindowsAzure.Storage library which he can do easily when you don't have the dll injected into the package. Otherwise you can get into some messy assemblies runtime errors.

您可以通过用于构建 nuget 包的 nuspec 文件控制包中包含的内容.

You control what your package contains via nuspec file used to build the nuget package.

这篇关于NuGet 包依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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