Nihlus/AdvancedDLSupport

Add support for NuGet package cache loading.

Perksey opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
Recently, when trying to distribute a package containing native packages with the intention of invoking them using ADL, I noticed that ADL would not find the library on a non-RID-specific build but DllImport can.

I then found out that DllImport also checks the NuGet cache for native assemblies, but ADL doesn't.

Describe the solution you'd like
We need to investigate the best way to search across multiple paths similar to CoreFX. This could be done internally, or we could expose an API similar to .NET Core 3's new NativeLibrary API and use DllImportSearchPaths.

Either way, we need to find out what paths we need to be looking in and then we can go from there.

Additional context

  • CoreFX doesn't copy native libraries unless you build with a RID specified.

A bit unrelated comment, but you have a typo here in .NET Core section: ManagedByRef should be ManagedByValue, it seems that it's just a copy of the actual ManagedByRef.

That deserves its own issue/PR I think.