Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuget Package #2

Open
vpenades opened this issue May 29, 2020 · 2 comments · May be fixed by #17
Open

Nuget Package #2

vpenades opened this issue May 29, 2020 · 2 comments · May be fixed by #17

Comments

@vpenades
Copy link

I think it could be interesting if the library could be available as a nuget package.

I've seen it mostly targets Unity, but there's life out of it...

@tstenner
Copy link
Contributor

I've pushed a first attempt here: https://github.com/labstreaminglayer/liblsl-Csharp/tree/nuget

The main problem is packaging / unpacking the native libraries somewhere the runtime looks when DllImporting liblsl and so far I haven't found anything that works.

glopesdev added a commit to glopesdev/liblsl-Csharp that referenced this issue Jun 15, 2021
@glopesdev glopesdev linked a pull request Jun 15, 2021 that will close this issue
@glopesdev
Copy link

@tstenner The current "official" way is to call SetDllDirectory or more generally simply depend on OS dynamic library resolution (e.g. using the PATH environment variable) to point to the appropriate runtimes folder inside the package: https://stackoverflow.com/questions/8836093/how-can-i-specify-a-dllimport-path-at-runtime/8861895#8861895

This has so far been done by detecting at runtime what platform the application is running under, then finding the location of the nuget package in the cache, and pointing the PATH to that folder before calling the P/Invoke layer. Some libraries opt to change their entire interop to use LoadLibrary instead, but that raises a number of maintenance issues IMO.

In .NET 5.0 there is NativeLibrary which can be used to leverage fast calls, but then you lose backwards compatibility with .NET framework. So far, the best tradeoff is still to simply use straight P/Invoke and setting the PATH environment variable.

I've pushed a new PR that expands the NuGet package declaration to include package tags, project URL and package license information, together with some documentation explaining how to build the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants