Summary
RuntimesFolderResolver fails on Ubuntu (and other distros missing from hardcoded _linuxRiDs list)
Problem
DefaultPathResolver.RuntimesFolderResolver fails to find native libraries in runtimes/linux-x64/native/ when running on Ubuntu because ubuntu is missing from the hardcoded _linuxRiDs array:
private static readonly string[] _linuxRiDs =
{
"alpine", "android", "arch", "centos", "debian", "exherbo", "fedora", "freebsd", "gentoo", "linux",
"opensuse", "rhel", "sles", "tizen", "pop"
};
GuessFallbackRid uses this list to decide whether to fall back from a distro-specific RID (e.g. ubuntu.24.04-x64) to linux-x64. Since ubuntu is not in the list, the method returns null and the resolver only searches runtimes/ubuntu.24.04-x64/native/ — which doesn't exist — and never reaches runtimes/linux-x64/native/.
Windows is unaffected because win has its own hardcoded fallback path (line 394-397) that doesn't depend on this list.
Reproduction
# On Ubuntu 24.04, build a project referencing Silk.NET.SDL (without -r)
dotnet build
# Run via dotnet vstest
dotnet vstest bin/Debug/net10.0/MyTests.dll
# -> FileNotFoundException: Could not load from any of the possible library names!
The native library exists at runtimes/linux-x64/native/libSDL2-2.0.so but is never found.
Suggested Fixes
Quick fix (fragile): Add missing distros (ubuntu, linuxmint, rocky, ol, amzn, ...) to _linuxRiDs. This will break again for any new distro not in the list.
Robust fix ideas:
if (OperatingSystem.IsLinux())
{
// Check with linux-x64/x86/arm/arm64 depending on RuntimeInformation.OSArchitecture
}
Environment
- Silk.NET 2.22.0
- .NET 10.0
- Ubuntu 24.04 (RID:
ubuntu.24.04-x64)
- Running via
dotnet vstest
Summary
RuntimesFolderResolverfails on Ubuntu (and other distros missing from hardcoded_linuxRiDslist)Problem
DefaultPathResolver.RuntimesFolderResolverfails to find native libraries inruntimes/linux-x64/native/when running on Ubuntu becauseubuntuis missing from the hardcoded_linuxRiDsarray:GuessFallbackRiduses this list to decide whether to fall back from a distro-specific RID (e.g.ubuntu.24.04-x64) tolinux-x64. Sinceubuntuis not in the list, the method returnsnulland the resolver only searchesruntimes/ubuntu.24.04-x64/native/— which doesn't exist — and never reachesruntimes/linux-x64/native/.Windows is unaffected because
winhas its own hardcoded fallback path (line 394-397) that doesn't depend on this list.Reproduction
The native library exists at
runtimes/linux-x64/native/libSDL2-2.0.sobut is never found.Suggested Fixes
Quick fix (fragile): Add missing distros (
ubuntu,linuxmint,rocky,ol,amzn, ...) to_linuxRiDs. This will break again for any new distro not in the list.Robust fix ideas:
Environment
ubuntu.24.04-x64)dotnet vstest