Application looking in wrong runtimes/{arch}/native directory
I have an application, that uses native code saved copied by its nuget into runtimes/ubuntu-x64/native directory. When I try to run it, it looks into the folder linux-x64 instead. My workaround is to just copy the contents, which works so far. But I am wondering, if I can somehow inform the program during building to look into the other directory instead
8 Replies
Have you tried setting an import resolver for the dlls?
No I havent tried that yet. Thank you
There's a property in .NET 6+ somewhere which tells you what RID the runtime considers itself to be. That value is used when evaluating the .deps.json file to locate native libraries.
So, two things. The runtime needs to think it's the correct RID. And second the .deps.json needs to be built correctly.
I do believe in .NET 8 and beyond, the runtime does not do distro specific RIDs. It will only return linux-x64 for ubuntu-x64.
Generally my approach here is to not write distro specific native libraries.
Sounds good. It is a nuget package that I am using, that copies to ubuntu-x64. So unfortunatly I do not have control over it. I think there are other linux distros which have slightly different dependencies, which is why they use this approach to not overwrite the libraries when multiple nugets are included in C#. Do you have advice how to handle it? For now I can just copy from ubuntu-x64 to linux-x64 since I dont use any other nugets. But if I did, is there some flags I could use to control which one is overwritten?
https://www.nuget.org/packages?q=emgu.cv.runtime
these are the packages
Those packages no doubt need to be updated for .NET 8.
https://learn.microsoft.com/en-us/dotnet/core/rid-catalog
>Loading assets for a specific OS version or distribution
>.NET no longer attempts to provide first-class support for resolving dependencies that are specific to an OS version or distribution. If your application or package needs to load different assets based on OS version or distribution, it should implement the logic to conditionally load assets.
.NET Runtime Identifier (RID) catalog - .NET
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
GitHub
[BUG] Linux runtime package is too specific. · Issue #617 · emgucv/...
Describe the bug From my understanding, for Linux, there is only one runtime package: Emgu.CV.runtime.ubuntu.20.04-x64. However, that is way too specific, and as a result the runtime is only going ...
<UseRidGraph>true</UseRidGraph>
is a temporary workaround to restore the old behavior
though, if you aren't on that specific ubuntu rid, it won't help anyway