Export Avalonia App To linux Ubuntu step-by-step guide
Mohammed Chami

Mohammed Chami @chami

About: Currently working on building desktop applications using WinForms and WPF also Avalonia UI.

Joined:
Jan 29, 2022

Export Avalonia App To linux Ubuntu step-by-step guide

Publish Date: Jun 13
2 3

The first way needs dotnet runtime to run, the second way I will share the self contained without dotnet runtime.

Need: dotnet runtime

Step 1: Install System-Wide .NET SDK (Required)

Open a terminal and run:

# Add Microsoft's repository
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 .NET 8 SDK
sudo apt update
sudo apt install -y dotnet-sdk-8.0

# Verify installation
dotnet --version
Enter fullscreen mode Exit fullscreen mode

Step 2: Install dotnet-deb Tool

dotnet tool install --global dotnet-deb
Enter fullscreen mode Exit fullscreen mode

Step 3: Prepare Your Avalonia Project

  1. Open your .csproj file
  2. Add these lines inside the <PropertyGroup> section:
<DebianPackage>true</DebianPackage>
<DebianPackageDependencies>libc6, libgcc1, libstdc++6</DebianPackageDependencies>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
Enter fullscreen mode Exit fullscreen mode

Step 4: Build the .deb Package

dotnet deb -c Release -r linux-x64
Enter fullscreen mode Exit fullscreen mode

This will create a .deb file in:

/bin/Release/net8.0/linux-x64/[your-app-name].deb


Step 5: Install on Ubuntu

sudo apt install ./bin/Release/net8.0/linux-x64/[your-app-name].deb
Enter fullscreen mode Exit fullscreen mode

Step 6: Run Your App

  • Find it in your application menu, or run via terminal:
[your-app-name]
Enter fullscreen mode Exit fullscreen mode

Troubleshooting Tips

1- Missing dependencies? Run:

   sudo apt install libx11-dev libgbm-dev libgl1-mesa-dev
Enter fullscreen mode Exit fullscreen mode

2- Not showing in app menu?

Check the generated .desktop file in:

/usr/share/applications/[your-app-name].desktop

3- Want a custom icon?

Add this to your .csproj:

   <DebianPackageIcon>path/to/your/icon.png</DebianPackageIcon>
Enter fullscreen mode Exit fullscreen mode

4- You must install .NET to run this application.

export DOTNET_ROOT=/usr/share/dotnet/
Enter fullscreen mode Exit fullscreen mode

Clean Uninstall Later

sudo apt remove [your-app-name]
Enter fullscreen mode Exit fullscreen mode

note: Self contained:
To create a self-contained .deb package that doesn't require users to install .NET separately, follow these steps:

1. Modify Your .csproj File

Add these properties to ensure a self-contained deployment:

<PropertyGroup>
  <!-- Enable self-contained deployment -->
  <SelfContained>true</SelfContained>
  <PublishSingleFile>true</PublishSingleFile>
  <RuntimeIdentifier>linux-x64</RuntimeIdentifier>

  <!-- Required for dotnet-deb -->
  <DebianPackage>true</DebianPackage>
  <DebianPackageDependencies>libc6, libgcc1, libstdc++6</DebianPackageDependencies>
</PropertyGroup>
Enter fullscreen mode Exit fullscreen mode

2. Publish & Build the .deb Package

Run this command to generate a standalone .deb:

dotnet publish -c Release -r linux-x64 --self-contained true
dotnet deb -c Release -r linux-x64
Enter fullscreen mode Exit fullscreen mode

This will output a .deb file in:

bin/Release/net8.0/linux-x64/[your-app-name].deb
Enter fullscreen mode Exit fullscreen mode

3. Key Improvements

  • No .NET Runtime Needed: The app bundles everything required.
  • Single Executable: PublishSingleFile reduces file clutter.
  • Debian Dependencies: Only basic system libs (libc6, etc.) are required.

4. Install & Test on Another Machine

sudo apt install ./your-app-name.deb
your-app-name
Enter fullscreen mode Exit fullscreen mode

The app should run without requiring dotnet installation.

Troubleshooting

If you get library errors, ensure these are installed:

sudo apt install libx11-dev libgbm-dev libgl1-mesa-dev
Enter fullscreen mode Exit fullscreen mode

Final notes

  • SelfContained=true bundles the .NET runtime inside your app.
  • PublishSingleFile merges DLLs into one executable.
  • The .deb package handles installation like any native app.

Thank you.

Comments 3 total

  • Admin
    AdminJun 13, 2025

    We’re thrilled to announce a limited-time token giveaway now live for Dev.to contributors to celebrate our authors' impact in Web3! Click here here (wallet connection required). – Dev.to Community Support

  • Spyros Ponaris
    Spyros PonarisJun 14, 2025

    Thanks for sharing !

Add comment