简体   繁体   English

如何制作具有系统依赖性的 nuget package?

[英]How to make a nuget package that have a system dependency?

I want to develop a C# binding to a package available on most Linux distributions (namely libnauty-dev ).我想开发一个 C# 绑定到大多数 Linux 发行版(即libnauty-dev )上可用的 package。 Something similar to: https://github.com/zajer/onauty .类似于: https://github.com/zajer/onauty

In OCaml I can make a virtual OPAM package that only checks whether the required system package is installed on a system and if it is then this OPAM package will be installed.在 OCaml 中,我可以创建一个虚拟 OPAM package,它只检查所需的系统 package 是否安装在系统上,如果是,则安装此 OPAM ZEFE90A8E604A7C840E88D03A6D87F6。 Also OPAM packages are distributed always with source code afaik so there is no problem with bundling c stubs with actual OCaml code.此外,OPAM 包始终与源代码 afaik 一起分发,因此将 c 存根与实际 OCaml 代码捆绑在一起没有问题。

Here are my questions:以下是我的问题:

  1. How can I bundle an.so file with my nuget package?如何将 an.so 文件与我的 nuget package 捆绑在一起?
  2. How can I check whether a necessary system package is available on the system?如何检查系统上是否有必要的系统package?

EDIT 1: To clarify things a bit, I need an answer for one of the questions since if I can distribute a nuget package with an.so library then that is all I need.编辑1:为了澄清一点,我需要一个问题的答案,因为如果我可以分发带有an.so库的nuget package,那么这就是我所需要的。 But if there is no way to distribute an.so file with a nuget then I need to build it while installing.但是,如果无法使用 nuget 分发 an.so 文件,那么我需要在安装时构建它。 And to do this I need to check if the required package is available on the system.为此,我需要检查系统上是否提供所需的 package。

Yes, you can include arbitrary files inside a NuGet package.是的,您可以在 NuGet package 中包含任意文件。 Fe add libnauty-dev.so to the folder where the.csproj is located, and add this to the.csproj, telling it to copy the binary to the output directory and to pack it: Fe将libnauty-dev.so添加到.csproj所在的文件夹,并将这个添加到.csproj中,告诉它把二进制文件复制到output目录下并打包:

<ItemGroup>
  <None Include="libnauty-dev.so" Pack="true" PackagePath=".\">
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    <PackageCopyToOutput>true</PackageCopyToOutput>
  </None>
</ItemGroup>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM