[英]How do I compile my C# library that uses external dependencies without them included in the library?
I am making my own C#
library that uses OpenTK
methods.我正在制作我自己的使用
OpenTK
方法的C#
库。 Naturally, I would have to include the OpenTK
dependencies in order to use them in my project.当然,我必须包含
OpenTK
依赖项才能在我的项目中使用它们。 When I compile my library and include it in my new project as a new external dependency, the OpenTK
dependencies are being included as well.当我编译我的库并将其作为新的外部依赖项包含在我的新项目中时,
OpenTK
依赖项也被包含在内。 My goal is to not include the OpenTK
dependencies within my self-made library that uses them, but rather have the user download required dependencies before using mine.我的目标是不在我使用它们的自制库中包含
OpenTK
依赖项,而是让用户在使用我的之前下载所需的依赖项。 Is that possible?那可能吗? Is that even a thing that matters?
这甚至是重要的事情吗? I am not familiar with libraries in C#.
我不熟悉 C# 中的库。
Nuget packages could help you here. Nuget 软件包可以帮助您。 Add OpenTK nuget package reference and share your library as nuget package.
添加 OpenTK nuget 包参考并将您的库作为 nuget 包共享。 In this case your nuget package won't have the assemblies of OpenTK instead will have a reference to OpenTK nuget package.
在这种情况下,您的 nuget 包不会包含 OpenTK 的程序集,而是会引用 OpenTK nuget 包。 When some one adds your package as a nuget package reference the nuget package installer looks for all other nuget package dependences and will install automatically.
当有人将您的包添加为 nuget 包引用时,nuget 包安装程序会查找所有其他 nuget 包依赖项并自动安装。
One caveat is that if you have any non-nuget package references in your package then those assemblies will be part of your nuget package itself.一个警告是,如果您的包中有任何非 nuget 包引用,那么这些程序集将成为您的 nuget 包本身的一部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.