Is it possible to include platform specific native binaries without packaging them?


#1

My end goal is to have a csproj that will (via dotnet publish while specifying a runtime) emit the platform specific libraries to the publish folder (without all the others). I can sort of do this at build time, but it is limited to determining which system I am building on, while I am looking for more of a cross-compilation style thing. Is there a way to identify which runtime is being targeted (similar to the $(OS) variables)? What I’d like is this:

dotnet publish -f netcoreapp1.1 -r win7-x64
    - MyNativeLib.dll
    - ManagedLib1.dll
    - ManagedLib2.dll
    - etc etc

dotnet publish -f netcoreapp1.1 -r osx-x64
    - myNativeLib.dylib
    - ManagedLib1.dll
    - ManagedLib2.dll
    - etc etc

dotnet publish -f netcoreapp1.1 -r ubuntu-16.04-x64
    - libMyNativeLib.so
    - ManagedLib1.dll
    - ManagedLib2.dll
    - etc etc

As you can see, the “MyNativeLib” that gets copied depends on the runtime being targeted. I know this is possible through Nuget packaging, but this native library is not one that normally gets packaged independently and creating a Nuget package seems like an obtuse solution.


.NET Foundation Website | Blog | Projects | Code of Conduct