- Open PowerShell as Administrator and run
wsl --install - Wait until the first components are installed and reboot !
- After the reboot wait until the WSL installation has completely finished
- Set up a username and password
- Run
sudo apt-get update && sudo apt-get upgrade
- Ubuntu (24.04) will be installed as default.
- Open PowerShell as Administrator and run
wsl --install Debian - Wait until the WSL installation has completely finished
- Set up a username and password
- Run
sudo apt-get update && sudo apt-get upgrade
- Debian (13.2) is now installed.
- Open PowerShell as Administrator and run
wsl --install FedoraLinux-43 - Wait until the WSL installation has completely finished
- Set up a username (and password)
- Run
sudo dnf check-update && sudo dnf upgrade
- Fedora (43) is now installed.
- In Visual Studio click Manage Extensions on the Extensions top menu
- In the search box, type Avalonia, click 'Download' and follow the instructions
- Inside Visual Studio: Select Tools on top -> Get Tools and Features
- OR Using the Visual Studio Installer: Select Modify on your Visual Studio Version
- Switch to the Individual components tab and search for WSL
- Select .NET Debugging with WSL and hit Modify to install
- Update using
sudo apt-get update && sudo apt-get upgrade
- Install using
sudo apt-get install libice6 libsm6
- Install using
sudo apt-get install dotnet-sdk-9.0 dotnet-sdk-8.0
- Update using
sudo apt-get update && sudo apt-get upgrade
- Install using
sudo apt-get install curl gpg wget libice6 libsm6 libfontconfig1 libx11-6 libx11-dev
- Install using
wget https://packages.microsoft.com/config/debian/13/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get install dotnet-sdk-9.0 dotnet-sdk-8.0
- Check for updates using
sudo dnf check-update - Update packages using
sudo dnf upgrade
- Install using
sudo dnf install awk curl gpg wget libICE libSM libX11 libX11-devel fontconfig freetype fontconfig-devel freetype-devel
- Install using
sudo dnf install dotnet-sdk-9.0 dotnet-sdk-8.0
- Start Visual Studio and select Create a new project
- Select C# as language, Linux as platform and Avalonia as project type
- Select the .NET App or .NET MVVM App depending on your requirements
- Give your project a name and select the .NET 8.0 or .NET 9.0 framework
- Select the Start Debugging ˅ (Context Menu) on top and select WSL
- This creates a launchSettings.json file inside a Properties folder in your project
- Simply hit Start Debugging or press F5 to debug your project in the default WSL distribution
- Open the created launchSettings.json file inside the Properties folder
- By default the file will look like :
{
"profiles": {
"AvaloniaApplication1": {
"commandName": "Project"
},
"WSL": {
"commandName": "WSL2",
"distributionName": ""
}
}
}- You can debug on another distribution by adding another launch profile like :
{
"profiles": {
"AvaloniaApplication1": {
"commandName": "Project"
},
"WSL : Debian 13.2": {
"commandName": "WSL2",
"distributionName": "Debian"
},
"WSL : Ubuntu 24.04": {
"commandName": "WSL2",
"distributionName": "Ubuntu"
},
"WSL : Fedora 43": {
"commandName": "WSL2",
"distributionName": "FedoraLinux-43"
}
}
}WSL : Debian 13.2defines the launch profile namecommandNameidentifies the debug target to rundistributionNametargets a specific distribution
- Open a Developer Command Prompt where your .csproj project file is located
- Execute
dotnet publish YOURPROJECT.csproj --nologo --configuration Release --self-contained true --runtime linux-x64 --output "./out/linux-x64"
- The folder ./out/linux-x64 will be created and contains your application compiled for Linux x64
- You can attach
/p:PublishSingleFile=true, this change produces a single file app on self-contained publish - You can also attach
/p:PublishTrimmed=true, this change will produce a trimmed app on self-contained publish
Please refer to this guide by Avalonia : https://docs.avaloniaui.net/docs/deployment/debian-ubuntu
- Install the required packaging tools on Fedora with
sudo dnf install fedora-packager rpmdevtools rpmbuild mock gcc - Move to a free directory and create a RPM skeleton with
rpmdev-setuptree - Change to the directory with
cd ~/rpmbuild
- Rename the compiled build folder /out/linux-x64 to APPLICATION_NAME-VERSION
- Example: linux-x64 -> MyApp-1.0.0
- Create a packaging folder inside the renamed compiled build folder
- Add an PNG icon with the name of your application APPLICATION_NAME.png into the packaging folder
- Add a Desktop shortcut for your application APPLICATION_NAME.desktop into the packaging folder, example :
[Desktop Entry]
Name=APPLICATION_NAME
Comment=APPLICATION_SHORT_DESCRIPTION
Icon=APPLICATION_NAME
Exec=APPLICATION_NAME
StartupWMClass=APPLICATION_NAME
Terminal=false
Type=Application
Categories=CATEGORY
GenericName=APPLICATION_NAME
Keywords=keyword1; keyword2; keyword3
- Replace APPLICATION_NAME, APPLICATION_SHORT_DESCRIPTION, CATEGORY and keywords with your project details
- Registered categories : https://specifications.freedesktop.org/menu/latest/category-registry.html
- You can validate the .desktop shortcut (on Fedora) with
desktop-file-validate APPLICATION_NAME.desktop
- Open a PowerShell Command Prompt on the parent folder of the compiled build folder
- Create a compressed tarball .tar.gz using
tar -czf build.tar.gz MyApp-1.0.0 - Copy the created compressed tarball build.tar.gz into the SOURCES folder back on Fedora
- Create a APPLICATION_NAME.spec file in the SPECS folder like :
Name: APPLICATION_NAME
Version: 1.0.0
Release: 1%{?dist}
Summary: APPLICATION_DESCRIPTION
License: LICENSE
URL: https://example.com
Source0: build.tar.gz
BuildArch: x86_64
Requires: libX11, gtk3, libGL
%description
APPLICATION_DESCRIPTION.
%global debug_package %{nil}
%prep
%setup -q
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/opt/%{name}
cp -a * %{buildroot}/opt/%{name}/
mkdir -p %{buildroot}/usr/share/applications
install -m 644 packaging/APPLICATION_NAME.desktop %{buildroot}/usr/share/applications/
mkdir -p %{buildroot}/usr/share/icons/hicolor/256x256/apps
install -m 644 packaging/APPLICATION_NAME.png %{buildroot}/usr/share/icons/hicolor/256x256/apps/
%files
/opt/%{name}
/usr/share/applications/APPLICATION_NAME.desktop
/usr/share/icons/hicolor/256x256/apps/APPLICATION_NAME.png
%changelog
* DATE_TODAY YOUR_NAME - 1.0.0-1
- Initial package
- Replace APPLICATION_NAME, APPLICATION_DESCRIPTION, LICENSE, URL, DATE_TODAY and YOUR_NAME with your project details
- Build with
rpmbuild -ba SPECS/APPLICATION_NAME.spec
- Error Unhandled exception. System.Exception: XOpenDisplay failed when testing in WSL :
- Execute
export DISPLAY=$(ip route | grep default | awk '{print $3}'):0.0and restart your WSL session
- Execute