Home: Creating a package for native / specialized runtimes

Created on 18 Jul 2016  路  9Comments  路  Source: NuGet/Home

I have two scenarios.
Scenario 1.
Say I have two C++ native implementation specific for Ubuntu14 and Windows.
But I am also able to provide a generic "IL-only" implementation which is very poor but that can be used as fallback for all the other platforms.
Question:
What are the steps to build the dlls and the packages?

Scenario 2.
I have two "IL-only" dotnetcore dlls but each one is specific for Ubuntu14 or Windows.
Then I want my asp.net app to reference automatically the OS-specific version depending on the runtime environment.
Question:
How can I build a package that trigger the correct DLL?

Thank you,

Most helpful comment

@karann-msft I resolved but the article was not really helpful since it talks about frameworks and not runtimes.
The reason why it took a long time for me to understand is that nuget website is lacking of the schema reference. Specifically there is not enough documentation about the following topics:

  • how to use the "ref" subfolder when the dev need to use reference assemblies
  • how to use the "native" subfolder when specifying native dependencies
  • the format of the subfolders (in terms of runtimes/platform/lib)

It is paradoxical and frustrating to lose time in reverse engineering the nuget stuff instead of finding the documentation written by people who architected and wrote the bits.

All 9 comments

@raffaeler nuget 3.x with project.json supports runtime specific assemblies which sound like what you are suggesting. Take a look at the help here: https://docs.nuget.org/create/uwp-create

I really hoped in some more detailed guide.
I already set-up some assemblies to test the solution but the resulting package is far from being working.
Also, there is so many obsolete documentation on the net that is extremely confusing.
If there is nothing better, I'll have to wait for spare time (which I definitely don't have till september)

@harikmenon - can you please work with @raffaeler here? docs request or feature request?

Thank you Rob, ... doc request, that's how most of the CoreFX libraries doing interop work. But looking at the sources is very dispersive.
I just want to avoid to waste time in guessing something that you guys already know how to do.

@raffaeler We would like to add these docs in the future. In the meantime, I believe you are looking for essentially bait and switch packages right?

If thats the case here is a post that walks through building this in detail

http://ryandavis.io/creating-and-publishing-a-cross-platform-library/ - This is basically derived from the plugins template in Xamarinf.

We hope to put out a doc explaining this in September. Currently we are focused on adding .NET Standard and UWP docs at this time.

@karann-msft can you please link this to a new docs issue on our end and track this for august end?

Thank you @harikmenon
The article talks about the PCLs. Are there any differences when packaging for .NET Core?
I would love to create:

  • a reference assembly dll defining the api surface
  • a platform neutral implementation (IL only)
  • a number of platform specific native dlls targeting each supported runtime (Win7x64, etc.)
    The main problem is the creation of one (or more) nuget packages with the correct structure.
    Thanks

No not really, you are essentially targeting Net Standard instead of portable profile at this point. Bait and switch is what I believe you are looking for here. Your reference assembly is the bait and platform assemblies are pulled in based on your target runtime.

@raffaeler here is the doc for bait and switch https://docspreview.nuget.org/ndocs/guides/create-cross-platform-packages

@karann-msft I resolved but the article was not really helpful since it talks about frameworks and not runtimes.
The reason why it took a long time for me to understand is that nuget website is lacking of the schema reference. Specifically there is not enough documentation about the following topics:

  • how to use the "ref" subfolder when the dev need to use reference assemblies
  • how to use the "native" subfolder when specifying native dependencies
  • the format of the subfolders (in terms of runtimes/platform/lib)

It is paradoxical and frustrating to lose time in reverse engineering the nuget stuff instead of finding the documentation written by people who architected and wrote the bits.

Was this page helpful?
0 / 5 - 0 ratings