Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: GtkSharp net6 workload #351

Merged

Conversation

trungnt2910
Copy link
Contributor

A .NET 6 Workload for GtkSharp. Should close #349.

What it can do:

Allow projects like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0-gtk</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="**\*.glade" />
    <EmbeddedResource Include="**\*.glade">
      <LogicalName>%(Filename)%(Extension)</LogicalName>
    </EmbeddedResource>
  </ItemGroup>

</Project>

to build, run and publish correctly, with a unique net6.0-gtk TFM and no package references.

Some changes I made:

  • Added a strong name key. The CreateFrameworkListFile target from Microsoft.DotNet.SharedFramework.Sdk, used to generate reference and runtime library packs, requires input assemblies to be signed, as it checks for a non-null PublicKeyToken. Furthermore, other .NET workload packs I know (Tizen, Xamarin,...) also have strong names.
  • Edited a few Directory.Build.props file, so that the workloads and the libraries can share a few build variables. This makes it easier for workload build scripts to locate output libraries for frameworks.

I hope this pull request can be considered. If there's anything in this PR against the project's rules, please let me know as soon as possible so that I can quickly fix the problem.

@trungnt2910
Copy link
Contributor Author

trungnt2910 commented May 12, 2022

A question about templates:
Other workloads also provide templates for the .NET SDK.
GtkSharp already has templates, however, these use the net6.0 TFM and references GtkSharp as a NuGet package.
Should I modify these files directly in this PR and include the existing templates in the workload, or make a separate workload template pack?

@lytico
Copy link
Member

lytico commented May 12, 2022

i would prefer separate workload template pack

@trungnt2910
Copy link
Contributor Author

i would prefer separate workload template pack

Done. I've added the workload packs for the three languages.
The templates in the workload pack:

  • Have Workload in their package names.
  • Use the target framework net6.0-gtk instead of net6.0 and do not reference the GtkSharp package.
  • Allow creating applications using dotnet new gtk instead of dotnet new gtkapp (to ensure parity with other workloads, such as dotnet new macos and dotnet new android, as well as avoiding clashes with the existing gtkapp templates).

@trungnt2910 trungnt2910 force-pushed the dev/trungnt2910/GtkSharpWorkload branch from aa5a4af to c80ce6b Compare May 27, 2022 10:14
@thomiel
Copy link

thomiel commented May 28, 2022

We had some testing of the .NET 6 workload at #maui-linux:matrix.org and it proved ok to use, although there seems to be an issue with the templates on Linux that is still under investigation. This is how you would test it (including a hack to make the templates appear) on Ubuntu 22.04:

# install dotnet 6
sudo apt-get update; \
sudo apt-get install -y apt-transport-https && \
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-6.0

# add keys
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

# install gtksharp with dotnet 6 support
git clone https://github.com/trungnt2910/GtkSharp.git
cd GtkSharp
sudo dotnet tool restore
sudo dotnet cake --BuildTarget=InstallWorkload 

# hack for making the templates visible in dotnet new
sudo cp /usr/share/dotnet/template-packs/* /usr/share/dotnet/templates/6.0.5

# install gtk
sudo apt-get install libgtk-3-0

# test gtk template
cd ..
mkdir gtksharptest
cd gtksharptest
dotnet new gtk
dotnet run

Having this included in an official release would be useful for our effort to establish Linux support for .NET MAUI (Multi-platform App UI).

@harry-cpp
Copy link
Member

Well, I'm low on time, so its time to merge first and ask questions later :D

Thanks @trungnt2910 !

@harry-cpp harry-cpp merged commit 60376ae into GtkSharp:develop May 29, 2022
@knocte
Copy link
Contributor

knocte commented Feb 13, 2023

@harry-cpp AFAIU, there's no version in nuget that has the feature yet. Why hasn't there been a release recently?

@trungnt2910
Copy link
Contributor Author

You might want to upvote #355.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GtkSharp net6 Workload
5 participants