How to bundle GTK indo single-file dotnet executable?

34 Views Asked by At

I am trying to bundle a GT3 application into a single file dotnet executable.

A minimal example like this:

mkdir x cd x dotnet new gtkapp dotnet build dotnet publish -r win-x64 -c Release -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentsForSelfExtract=true -p:PublishReadyToRun=true --self-contained true

produces an executable in bin\Release\net6.0\win-x64\publish\x.exe that works just fine on any machine, that has GTK installed. On Windows without GTK nothing happens, not even an error message is produced when running this x.exe that should to my understanding have everything included.

With a bigger example (too big to post here), I get an error message:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Gtk.Application' threw an exception. ---> System.DllNotFoundException: Gtk: libgtk-3-0.dll, libgtk-3.so.0, libgtk-3.0.dylib, gtk-3.dll at GLibrary.Load(Library library) at Gtk.Application..cctor() --- End of inner exception stack trace --- at Gtk.Application.Init()

I have also tried skipping some cli arguments of the publish command, but nothing helped.

What could be the problem?

Tried to bundle a GTK application into a single dotnet executable. Expected, that it could be executed on other Windows machines. Minimal example showed no function at all, greater example crashed with DLLNotFoundException.

0

There are 0 best solutions below