mono / gtk-sharp

Gtk# is a Mono/.NET binding to the cross platform Gtk+ GUI toolkit and the foundation of most GUI apps built with Mono
http://www.mono-project.com/GtkSharp
Other
424 stars 140 forks source link

Publish NuGet packages #231

Open jeremyVignelles opened 6 years ago

jeremyVignelles commented 6 years ago

I'm trying to integrate libvlc with GTK# (see the work in progress here : https://github.com/jeremyVignelles/libvlcsharp/tree/feature/gtk-sharp )

However, the fact that this is a reference to a DLL file and not to a NuGet package makes it very inconvenient to write and maintain in cross-platform scenarios :

https://github.com/jeremyVignelles/libvlcsharp/blob/feature/gtk-sharp/LibVLCSharp.Platforms.Gtk/LibVLCSharp.Platforms.Gtk.csproj#L11-L35

In our customer's csproj, they also need to depend on each dll as well:

https://github.com/jeremyVignelles/libvlcsharp/blob/feature/gtk-sharp/LibVLCSharp.Gtk.Sample/LibVLCSharp.Gtk.Sample.csproj#L18-L46

EDIT: And we didn't even try to make it work on Mac OS

Would it be possible to create an official NuGet package for that ?

SteveGilham commented 5 years ago

There's actually a simpler way to do a build (for Windows and Linux, at least), relying on the fact that the gtk-sharp-2.xx.4yy.msi install registers the GTK# assemblies into the GAC on the Windows machine for its known location, and adds the GTK binaries to the PATH. With a similar sane default PATH (or LD_LIBRARY_PATH) setting (which seems to come "out of the box" on the travis-ci servers at least), there's no need to specify a path to the assemblies, just their names.

For a working example, see https://github.com/SteveGilham/altcover/blob/master/AltCover.Visualizer/AltCover.Visualizer.fsproj#L108-L125 (ignore the F# assembly that's in the middle in alphabetical order). This project builds happily on Windows (once I've done a cinst gtksharp on AppVeyor) and on Linux with mono without any particular set-up on my part (see e.g. https://travis-ci.org/SteveGilham/altcover/builds/417700678 line 2503-2612 for the latter).

That said, a NuGet package containing a truly cross-platform netstandard2.0 build would still be awesome, though that would require some level of re-architecting to separate out the platform independent and runtime dependent pieces of the code : the C# code builds happily from new-style dotnet projects targeting netstandard2.0 -- it doesn't use any particularly funky .net APIs -- but it currently does all its OS dependent dispatching at build time.

On the up-side, it would make a mature GUI framework truly cross-platform, rather than having to look to lowest-common-denominator and evolving SDKs like AvaloniaUI for the purpose.

jeremyVignelles commented 5 years ago

Thanks @SteveGilham, I'm back to the code after a long time and tried your suggestion. Unfortunately, it doesn't seem to work for sdk-style projects. gacutil /l shows the files correctly, but the project can't find the reference, and nothing is found under "Add reference/Extensions". On a WPF "classic" project, I can see gtk-sharp and friend in this dialog. nothing found in Extensions

I guess I'll have to live with ugly conditions somehow