2

What's the story going to be (if any) around interop with unmanaged code for ASP.net vNext / Core CLR?

The key bits (DllImport and friends) appear to be present to allow for unmanaged code interop, but how would things such as packaging and deployment work in this context? The basic build artifact in vNext / CoreFX no longer appears to be an assembly, but a NuGet package. So in that case, how would we make the new project.json system work so that unmanaged dlls that we're P/Invoking into are also included in the resulting NuGet package?

Or am I talking about scenarios that have not been considered yet (or more disappointingly, not going to happen)?

Eilon
  • 25,582
  • 3
  • 84
  • 102
jumpinjackie
  • 2,387
  • 4
  • 22
  • 26

1 Answers1

5

The story is yet to be fully fleshed out, but there are already examples of how to do this. Ultimately we (the Microsoft teams working on this) are working on some scenarios to enable NuGet packages to better support native content in packages.

To see one example of this, the Kestrel web server has some of its own managed code, plus it includes libuv in its NuGet package for an efficient async IO implementation that is cross-platform.

Because there isn't yet a built-in general solution in NuGet, the build scripts for Kestrel use some custom actions to include the native content in the NuGet package. Then to load libuv there's some code that dynamically figures out which native libuv to load based on the environment in which it is running.

So, yeah, it's a bit messy, but it does work, and this is definitely high on the team's priority list to improve.

Eilon
  • 25,582
  • 3
  • 84
  • 102
  • That's good to hear. If we take your hypothetical libuv package, would we be able to create an a single xplat nuget package (w/ native windows/unix/osx binaries included), or would we have to go with per-platform packages? – jumpinjackie Jan 16 '15 at 10:10
  • @JackieNg One Package To Rule Them All, would be the idea, just like the Kestrel package, which is not hypothetical - it's a real package. It has what it needs to run on Win7+, Win2K8 R2+, OS X, and *nix. – Eilon Jan 16 '15 at 16:19