libsodium-net icon indicating copy to clipboard operation
libsodium-net copied to clipboard

DNX Support

Open raymens opened this issue 9 years ago • 8 comments

Adding this library to an ASP.NET 5 RC1 project causes a runtime error of not finding the libsodium.dll file. So it seems the Baseclass.Contrib.Nuget.Output package doesn't do it's job anymore?

raymens avatar Nov 23 '15 13:11 raymens

@raymens are you using the newest libsodium-net package (0.9.0-beta5)?

bitbeans avatar Nov 23 '15 13:11 bitbeans

@bitbeans Yup

Update: Copying the %userprofile%\.dnx\packages\libsodium-net\0.9.0-beta5\output\libsodium.dll file to %userprofile%\.dnx\packages\libsodium-net\0.9.0-beta5\lib\Net40 seems to fix this.

raymens avatar Nov 23 '15 13:11 raymens

I`am not the DNX specialist, but i think there is no output folder, to copy from? https://github.com/baseclass/Contrib.Nuget#baseclasscontribnugetoutput

So, you are right :)

bitbeans avatar Nov 23 '15 13:11 bitbeans

See the update in my previous message that I just posted when you posted your answer. Seems to be a workaround for development.

raymens avatar Nov 23 '15 13:11 raymens

The use of Baseclass.Contrib.Nuget.Output has addressed the issue of how to distribute the unmanaged binaries, as because of how NuGet works, they can't be dropped in the lib folder. But, it's also caused more than its share of issues.

Long term, we may need to find a better way of dealing with these files in the NuGet package.

adamcaudill avatar Jan 18 '16 05:01 adamcaudill

Maybe this can help ? http://blog.3d-logic.com/2015/11/10/using-native-libraries-in-asp-net-5/ (not my blog).

rwasef1830 avatar Feb 20 '16 23:02 rwasef1830

I found a viable workaround for using libsodium-net in DNX projects (tested on RC1) currently.

Just add a class library (package) project and reference it from the main app project.json.

The class library project.json should look like this:

{
    "version": "1.0.0",

    "frameworks": {
        "dnx451": { }
    },

    "packInclude": {
        "runtimes/": "runtimes/**"
    }
}

Next, make the directory structure inside the class library project look like this:

<project root>
|_ project.json
|_ runtimes
    |_win7-x64
    |  |_ native
    |      |_ libsodium.dll (from "output" dir of nuget package and rename it from libsodium-64.dll)
    |_ win7-x86
       |_ native
           |_ libsodium.dll (from "output" dir of nuget package)

With libsodium-net also referenced in project.json of main app, now it works without giving "cannot find dll" exception.

Example by MS: https://github.com/aspnet/dnx/tree/dev/misc/DllImportTestProjects/src

Hope that helps anyone until this bug is fixed (tested on 0.9.0 version on ASP.net 5 RC1 and VS2015).

rwasef1830 avatar Feb 20 '16 23:02 rwasef1830

See also: Issue #148

jaredthirsk avatar Mar 04 '17 09:03 jaredthirsk