简体   繁体   中英

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 ). Something similar to: 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. Also OPAM packages are distributed always with source code afaik so there is no problem with bundling c stubs with actual OCaml code.

Here are my questions:

  1. How can I bundle an.so file with my nuget package?
  2. How can I check whether a necessary system package is available on the system?

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. But if there is no way to distribute an.so file with a nuget then I need to build it while installing. And to do this I need to check if the required package is available on the system.

Yes, you can include arbitrary files inside a 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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