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

Added guide for packaging .NET apps #408

Merged
merged 25 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
e768eec
Added guide for packaging .NET apps
gridlocdev Aug 19, 2023
b1769f4
Updated .NET guide's relative Sandbox Permissions page link to use fu…
gridlocdev Aug 19, 2023
731534b
Added Tagging to .NET guide example
Aug 20, 2023
e0260f3
Updated .NET guide to use .NET 6, replaced placeholder symbol
Aug 20, 2023
5667c39
Updated help verbiage on .NET guide
Aug 20, 2023
b23ddbe
Fixed typo in example Tag attribute
gridlocdev Aug 20, 2023
cea78f1
.NET guide: Removed unneeded path prefix from build copy command
gridlocdev Aug 20, 2023
08d48ad
.NET guide: Fixed version typo, updated to prepend-pkg-config-path, a…
gridlocdev Aug 20, 2023
079be4a
.NET guide: Moved IPC share finish argument underneath other X11 argu…
gridlocdev Aug 20, 2023
73420e4
Merge branch 'flatpak:master' into master
gridlocdev Jul 23, 2024
f60dad6
Update .NET linux desktop UI frameworks list
gridlocdev Jul 23, 2024
3fed78b
Update .NET guide to use .NET 8 and latest stable FreeDesktop SDK
gridlocdev Jul 23, 2024
2c40161
Simplified .NET guide dependency install steps, updated placeholder n…
gridlocdev Jul 23, 2024
fe49811
update AvaloniaUI url in .NET guide to avoid redirect
gridlocdev Jul 23, 2024
854397a
Update whitespace of .NET guide for better readability
gridlocdev Jul 23, 2024
117c15a
Corrected name of Uno framework in .NET guide
gridlocdev Jul 23, 2024
844b406
Merge branch 'flatpak:master' into master
gridlocdev Jul 23, 2024
a14e8dd
Use RST cross-reference syntax for .NET guide links
gridlocdev Jul 23, 2024
baa3f6a
updated .NET guide's links' RST syntax
gridlocdev Jul 23, 2024
7640bfb
Update .NET guide so only distribution package of flatpak-builder is …
gridlocdev Jul 23, 2024
bfece9a
Cleaned up .NET guide placeholder names and refined dependency instal…
gridlocdev Jul 23, 2024
163ce05
Fix text of a few items on .NET guide
gridlocdev Jul 24, 2024
e6cb3c3
Updated build step of .NET guide too only download and not build
gridlocdev Jul 24, 2024
24a6ec9
Removed Git tag from .NET guide
gridlocdev Jul 24, 2024
11cdf70
Add ``First Build` as pre-requisite for .NET guide
gridlocdev Jul 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions docs/dotnet.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
Dotnet
======

Prerequisites
~~~~~~~~~~~~~
- :doc:`first-build`
- The application is built with a Linux-compatible .NET desktop application framework such as:
- `Avalonia UI <https://avaloniaui.net/>`_
- `Uno Platform <https://platform.uno/>`_
- `Eto <https://github.com/picoe/Eto>`_
- `GTKSharp <https://github.com/GtkSharp/GtkSharp>`_
- The application's source code is hosted on a Git server such as GitHub, GitLab, or Bitbucket

Steps for Packaging
~~~~~~~~~~~~~~~~~~~

Installing Flatpak and Flatpak builder
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1. Install Flatpak using the method provided for your distribution
`Flatpak - Quick Setup <https://flatpak.org/setup/>`_

2. Install Flatpak Builder through your distribution package manager (e.g. ``apt`` / ``dnf``)

.. code-block:: shell

sudo apt install flatpak-builder


Creating the Flatpak
^^^^^^^^^^^^^^^^^^^^

A few placeholders have been used in the steps below, while going through the steps replace these with the ones respective to your project:

- ``<app-id>``: The name of your Flatpak, see :ref:`conventions:application ids`.
- ``<app-name>``: The name of the root folder of your app repository
- ``<project-name>``: The name of your ``.csproj`` file
- ``<git-url>``: The URL to the git repository of the project

3. Create a new folder somewhere different from your existing project

4. Create a YAML file titled ``<app-id>.yaml`` with the following example template, replacing the placeholders with the appropriate information. (Note: If your project file lives in a subfolder, be sure to include that in the build paths in this file and subsequent commands as well.):

.. code-block:: yaml

id: <app-id>
runtime: org.freedesktop.Platform
runtime-version: '23.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.dotnet8
build-options:
prepend-path: "/usr/lib/sdk/dotnet8/bin"
append-ld-library-path: "/usr/lib/sdk/dotnet8/lib"
prepend-pkg-config-path: "/usr/lib/sdk/dotnet8/lib/pkgconfig"

command: <project-name>

finish-args:
- --device=dri
# TODO: Replace this with wayland and fallback-x11 once Wayland support
# becomes available:
# https://github.com/AvaloniaUI/Avalonia/pull/8003
- --socket=x11
- --share=ipc
- --env=DOTNET_ROOT=/app/lib/dotnet

modules:
- name: dotnet
buildsystem: simple
build-commands:
- /usr/lib/sdk/dotnet8/bin/install.sh

- name: <app-name>
buildsystem: simple
sources:
- type: git
url: <git-url>
- ./nuget-sources.json
build-commands:
- dotnet publish <project-name>.csproj -c Release --no-self-contained --source ./nuget-sources
- mkdir -p ${FLATPAK_DEST}/bin
- cp -r bin/Release/net8.0/publish/* ${FLATPAK_DEST}/bin

.. note::

For providing access to other things such as the network or
filesystem, see :doc:`sandbox-permissions`

5. Copy and save the dotnet NuGet sources generator script
``flatpak-dotnet-generator.py`` from the `Flatpak Builder Tools
repository <https://github.com/flatpak/flatpak-builder-tools>`_, to
the current folder, or run the following command to download it:

.. code-block:: shell

wget https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/dotnet/flatpak-dotnet-generator.py

6. Clone down your project repository to the folder

.. code-block:: shell

git clone <git-url>

7. Install dependencies from Flathub

.. code-block:: shell

flatpak-builder build-dir --user --install-deps-from=flathub --download-only <app-id>.yaml

8. Run the NuGet source config generator script ``flatpak-dotnet-generator.py`` with the following arguments:

.. code-block:: shell

python3 flatpak-dotnet-generator.py --dotnet 8 --freedesktop 23.08 nuget-sources.json <app-name>/<project-name>.csproj

9. Build and install using Flatpak builder

.. code-block:: shell

flatpak-builder build-dir --user --force-clean --install --repo=repo <app-id>.yaml
bbhtt marked this conversation as resolved.
Show resolved Hide resolved


Testing the build
^^^^^^^^^^^^^^^^^

10. Run the installed Flatpak application

.. code-block:: shell

flatpak run <app-id>

1 change: 1 addition & 0 deletions docs/guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ standard guidance provided elsewhere in the Flatpak documentation.

python
electron
dotnet
qt
multiarch
extension