简体   繁体   English

如何编译使用外部依赖项而不将它们包含在库中的 C# 库?

[英]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.

相关问题 如何将C#代码编译为库而不是可执行文件? - How do I compile C# code as a library instead of an executable? 我如何获得像HTML敏捷性这样的外部库来在我的C#项目中工作? - How Do I Get External LIbrary Like Html Agility To Work In My C# Project? 如何使用使用 C# .NET Core REST API 中的库的客户端重命名 JsonPropertyName - How do I rename a JsonPropertyName with a client that uses a library in C# .NET Core REST API 在c#中没有外部库的序列化/反序列化 - Serialize/deserialize without external library in c# Enterprise Architect:如何添加我包含的程序集 (C# .NET 4) 以便我可以使用它们? - Enterprise Architect: How do I add my included assemblies (C# .NET 4) so I can use them? 为什么我使用库 A 的 C# 客户端需要对库 B(A 使用)有一个 using 语句 - why does my C# client that uses Library A need to have a using statement for Library B (which A uses) ac#库的链接依赖关系 - Link dependencies of a c# library 如何在不使用C#的库的情况下修改PDF并将其流回ASP.NET中的客户端? - How do I modify PDF without a library using C# and stream it back to client in ASP.NET? 如何测量C#应用程序使用的FLOPS? - How do I measure the FLOPS my C# app uses? 如何部署使用C ++ / CLI库的C#库 - How to deploy a C# library that uses C++/CLI libraries
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM