AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
26.04k stars 2.25k forks source link

Avalonia application does not run from WSL Ubuntu 24 #17538

Closed TangDave closed 4 days ago

TangDave commented 5 days ago

Describe the bug

I'm building using 'dotnet publish' - this seems to complete just fine, using separate commands to produce separate output for Windows and Linux. The Windows application runs fine. The Linux application produces the following exception when trying to run on WSL2 Ubuntu 24:

Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: /home/unixdave/.local/TestApp/libSkiaSharp.so: cannot open shared object file: No such file or directory /home/unixdave/.local/TestApp/liblibSkiaSharp.so: cannot open shared object file: No such file or directory /home/unixdave/.local/TestApp/libSkiaSharp: cannot open shared object file: No such file or directory /home/unixdave/.local/TestApp/liblibSkiaSharp: cannot open shared object file: No such file or directory

at SkiaSharp.SkiaApi.sk_colortype_get_default_8888() at SkiaSharp.SKImageInfo..cctor() --- End of inner exception stack trace --- at Avalonia.Skia.PlatformRenderInterface..ctor(Nullable1 maxResourceBytes) at Avalonia.Skia.SkiaPlatform.Initialize(SkiaOptions options) at Avalonia.SkiaApplicationExtensions.<>c.<UseSkia>b__0_0() at Avalonia.AppBuilder.SetupUnsafe() at Avalonia.AppBuilder.Setup() at Avalonia.AppBuilder.SetupWithLifetime(IApplicationLifetime lifetime) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, Action1 lifetimeBuilder) at TestApp.Program.Main(String[] args)

Shouldn't the "dotnet publish" with parameters "-r linux-x64 --self-contained true -c Release -p:PublishSingleFile=true" produce an executable with all it needs to run on 64-bit Linux? Do I need a full-fledged Linux machine just to test an Avalonia application for Linux?

To Reproduce

Build Linux target using following command from Windows: dotnet publish <C# project path> -r linux-x64 --self-contained true -c Release -p:Platform=x64 -p:PublishSingleFile=true -o

Copy to Linux file system on WSL2 Ubuntu 24 on same machine and set permission for executable via "wsl chmod +x TestApp" from terminal.

Attempt to run via "wsl ./TestApp".

Expected behavior

No response

Avalonia version

11.2.0

OS

Linux

Additional context

No response

timunie commented 5 days ago

Libskiasharp is a native dependenc which is not included in the single file by default. Try to copy these over in addition or check in ms docs how to include these as well

TangDave commented 4 days ago

Thanks - I think removing the "PublishSingleFile" takes care of it. I don't understand why there are both 'so' files (I believe these are native Linux binaries) in addition to 'dll' files - aren't dll files just for Windows? Why are they included?