NuGet Package Dependencies

懵懂的女人 提交于 2020-04-13 03:42:56

问题


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?

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

NuGet Dependencies

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?


回答1:


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

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.

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.

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



来源:https://stackoverflow.com/questions/28229892/nuget-package-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!