Flatpak support
One way developing and distributing gui apps for Linux is to create sandboxed apps via flatpak or snap.
Add some new integration project which adds some msbuild task (written in C#) to create a flatpak.
This could be independent of GirCore. Perhaps there is already a solution available?
Hi.
To package an app into Flatpak, you need to create a YAML (or JSON) manifest that defines the runtime environment, permissions, and environment variables. After that, you have to call an external tool to actually build the package.
This kind of stuff is better automated with a bash script, in my opinion. Writing it as an MSBuild task feels like overkill, especially since different applications may require more flexible Flatpak manifest configurations.
There needs to be a some kind of defined feature set first before there should be some implementation.
I'm not very much into flatpak currently.
What I saw until now that there are often long lists of DLLs which need to be included. Perhaps this could be somehow automated?
If you have experience with flatpak can you give some step by step description what has to be done and configured to have a working flatpak and perhaps even a published flatpak on flathub?
Then there could be thoughts about a possible way forward and how to make flatpak generation and publishing as easy and flexible as possible.
I'm not a flatpak expert (others put together the Pinta flatpak), but I think it used https://github.com/flatpak/flatpak-builder-tools/tree/master/dotnet to deal with the nuget sources
In one of my PoC projects I used this bash script:
#!/bin/bash
set -e # Stop on errors
APP_ID="com.example.githubapp"
MANIFEST="flatpak-manifest.yaml"
BUILD_DIR="build-dir"
REPO_DIR="repo"
FLATPAK_FILE="GithubApp.flatpak"
echo "Cleaning up old builds..."
rm -rf $BUILD_DIR $REPO_DIR ./app $FLATPAK_FILE
echo "Building .NET project..."
dotnet publish ./GithubApp.Host/GithubApp.Host.csproj -c Release -r linux-x64 --self-contained true -p:PublishAot=true -p:EnableCompressionInSingleFile=true -p:InvariantGlobalization=true -p:StripSymbols=true -p:IlcOptimize=true -p:IlcGenerateDebugInfo=false -p:TrimMode=Full -o ./app
echo "Running Flatpak Builder..."
flatpak-builder --install-deps-from=flathub --force-clean $BUILD_DIR $MANIFEST
echo "Exporting build to repository..."
flatpak build-export $REPO_DIR $BUILD_DIR
echo "Creating .flatpak file..."
flatpak build-bundle $REPO_DIR $FLATPAK_FILE $APP_ID
echo "Removing build artifacts..."
rm -rf $BUILD_DIR $REPO_DIR ./app
echo "Build complete: $FLATPAK_FILE"
And here’s the Flatpak manifest I used:
app-id: com.example.githubapp
runtime: org.gnome.Platform
runtime-version: "47"
sdk: org.gnome.Sdk
command: GithubApp.Host
finish-args:
- --socket=x11
- --socket=wayland
- --share=network
- --filesystem=xdg-config
- --device=dri
- --env=GDK_BACKEND=x11
modules:
- name: githubapp
buildsystem: simple
build-commands:
- mkdir -p /app/bin
- cp -r * /app/bin/
- chmod +x /app/bin/GithubApp.Host
sources:
- type: dir
path: app
The main issue is that you need to have a prepared flatpak manifest. And settings in that manifest aren’t exactly straightforward. That's why I said that using a build task for this doesn't seem like a great idea, in my opinion.
There is already a dotnet project for this purpose. You can use PupNet.
It supports multiple packaging formats, including flatpak. You probaby need to change some options (e.g. FlatpakPlatformRuntime, FlatpakPlatformSdk, etc.) to the gnome version.