Files
appimage/README.md

218 lines
6.0 KiB
Markdown
Raw Normal View History

2026-01-24 03:39:33 +00:00
## What is AppImage?
AppImage is a universal Linux package format that allows you to distribute applications as a single executable file that works on most Linux distributions without installation.
## Features
- Package any .NET MAUI Linux app as an AppImage
2026-01-24 07:28:28 +00:00
- **Auto-detection** of executable and icon from your project
- Automatic `.desktop` file generation with proper `StartupWMClass` for taskbar integration
- Built-in installer dialog on first run
- Install/Reinstall/Uninstall support
2026-01-24 03:39:33 +00:00
- No root access required
## Prerequisites
1. **.NET 9 SDK** or later
2. **appimagetool** - Download from [AppImageKit releases](https://github.com/AppImage/AppImageKit/releases)
### Installing appimagetool
```bash
# Download
wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
# Make executable
chmod +x appimagetool-x86_64.AppImage
# Move to PATH
sudo mv appimagetool-x86_64.AppImage /usr/local/bin/appimagetool
```
## Installation
### As a .NET tool (recommended)
```bash
dotnet tool install --global OpenMaui.AppImage
```
### From source
```bash
git clone https://github.com/AuroraNetworks/openmaui-appimage.git
cd openmaui-appimage
dotnet build
```
## Usage
### 1. Publish your MAUI app
```bash
cd YourMauiApp
2026-01-24 07:28:28 +00:00
dotnet publish -c Release -r linux-x64 --self-contained
2026-01-24 03:39:33 +00:00
```
### 2. Create the AppImage
```bash
openmaui-appimage \
--input bin/Release/net9.0/linux-x64/publish \
--output YourApp.AppImage \
2026-01-24 07:28:28 +00:00
--name "Your App"
2026-01-24 03:39:33 +00:00
```
2026-01-24 07:28:28 +00:00
That's it! The tool automatically detects:
- **Executable**: Finds the main executable (ELF binary or .runtimeconfig.json)
- **Icon**: Reads `MauiIcon` from your `.csproj` and composites background + foreground
2026-01-24 03:39:33 +00:00
### Options
| Option | Short | Required | Description |
|--------|-------|----------|-------------|
| `--input` | `-i` | Yes | Path to published .NET app directory |
| `--output` | `-o` | Yes | Output AppImage file path |
| `--name` | `-n` | Yes | Application name |
2026-01-24 07:28:28 +00:00
| `--executable` | `-e` | No | Main executable name (auto-detected if not specified) |
| `--icon` | | No | Path to icon (auto-detected from MauiIcon if not specified) |
2026-01-24 03:39:33 +00:00
| `--category` | `-c` | No | Desktop category (default: Utility) |
2026-01-24 07:28:28 +00:00
| `--app-version` | | No | App version (default: 1.0.0) |
2026-01-24 03:39:33 +00:00
| `--comment` | | No | App description |
### Desktop Categories
Common categories: `Utility`, `Development`, `Game`, `Graphics`, `Network`, `Office`, `AudioVideo`, `System`
## Running the AppImage
2026-01-24 07:28:28 +00:00
### First Run - Installer Dialog
When you run an AppImage for the first time, a dialog appears:
- **Install**: Copies to `~/.local/bin`, creates menu entry and icon
- **Run Only**: Runs the app without installing
### Already Installed
If you run the AppImage again from a different location (e.g., Desktop), you'll see options:
2026-01-24 03:39:33 +00:00
2026-01-24 07:28:28 +00:00
- **Run the application**: Just runs it
- **Reinstall (update)**: Updates the installed version
- **Uninstall**: Removes the app from your system
### From the Launcher
Once installed, clicking the app in your application menu runs it directly (no dialog).
### Command Line Flags
```bash
# Run normally (shows dialog if not installed)
2026-01-24 03:39:33 +00:00
./YourApp.AppImage
2026-01-24 07:28:28 +00:00
# Force install dialog
2026-01-24 03:39:33 +00:00
./YourApp.AppImage --install
# Uninstall
./YourApp.AppImage --uninstall
2026-01-24 07:28:28 +00:00
# Show help
./YourApp.AppImage --help
2026-01-24 03:39:33 +00:00
```
## Example: Packaging ShellDemo
```bash
# Build and publish
cd maui-linux-samples/ShellDemo
2026-01-24 07:28:28 +00:00
dotnet publish -c Release -r linux-x64 --self-contained
2026-01-24 03:39:33 +00:00
2026-01-24 07:28:28 +00:00
# Create AppImage (icon auto-detected from MauiIcon in csproj)
2026-01-24 03:39:33 +00:00
openmaui-appimage \
-i bin/Release/net9.0/linux-x64/publish \
-o ShellDemo.AppImage \
2026-01-24 07:28:28 +00:00
-n "Shell Demo"
2026-01-24 03:39:33 +00:00
```
## How It Works
1. **AppDir Structure**: Creates the standard AppImage directory structure:
```
YourApp.AppDir/
├── AppRun # Entry point script
├── YourApp.desktop # Desktop integration
├── YourApp.svg # Application icon
└── usr/
2026-01-24 07:28:28 +00:00
├── bin/ # Your published .NET app
│ └── appicon.svg # Runtime icon for window
└── share/icons/ # XDG icon directories
2026-01-24 03:39:33 +00:00
```
2. **AppRun Script**: A bash script that:
- Sets up the environment (PATH, LD_LIBRARY_PATH)
2026-01-24 07:28:28 +00:00
- Shows installer dialog on first run
- Handles `--install`, `--uninstall`, and `--help` flags
- Launches the .NET application
3. **Desktop Integration**:
- Creates `.desktop` file with `StartupWMClass` for proper taskbar icon matching
- Installs icon to XDG icon directories
- Updates icon cache automatically
2026-01-24 03:39:33 +00:00
2026-01-24 07:28:28 +00:00
4. **appimagetool**: Packages everything into a single executable AppImage file
2026-01-24 03:39:33 +00:00
## Self-Contained vs Framework-Dependent
2026-01-24 07:28:28 +00:00
### Self-Contained (recommended for distribution)
2026-01-24 03:39:33 +00:00
```bash
2026-01-24 07:28:28 +00:00
dotnet publish -c Release -r linux-x64 --self-contained
2026-01-24 03:39:33 +00:00
```
2026-01-24 07:28:28 +00:00
- Works on any Linux system without .NET installed
- Larger AppImage size
2026-01-24 03:39:33 +00:00
2026-01-24 07:28:28 +00:00
### Framework-Dependent (smaller size)
2026-01-24 03:39:33 +00:00
```bash
2026-01-24 07:28:28 +00:00
dotnet publish -c Release -r linux-x64 --self-contained false
2026-01-24 03:39:33 +00:00
```
2026-01-24 07:28:28 +00:00
- Smaller AppImage (~50-100MB smaller)
- Requires .NET runtime on target system
2026-01-24 03:39:33 +00:00
## Troubleshooting
### "appimagetool not found"
Install appimagetool as described in Prerequisites.
### "Could not find executable"
2026-01-24 07:28:28 +00:00
The auto-detection looks for:
1. ELF binaries (self-contained apps)
2. `.runtimeconfig.json` files (framework-dependent apps)
If it fails, use `--executable` to specify the correct name (without extension).
2026-01-24 03:39:33 +00:00
### AppImage won't run
1. Ensure it's executable: `chmod +x YourApp.AppImage`
2. Check for missing dependencies: `./YourApp.AppImage` (errors will be shown)
2026-01-24 07:28:28 +00:00
### Taskbar icon not showing
The app sets `WM_CLASS` and the `.desktop` file includes `StartupWMClass` for proper matching. If issues persist:
1. Reinstall the app to update the `.desktop` file
2. Log out and back in to refresh the desktop environment
2026-01-24 03:39:33 +00:00
### FUSE errors
Some systems require FUSE to mount AppImages. Install with:
```bash
sudo apt install fuse libfuse2 # Debian/Ubuntu
sudo dnf install fuse fuse-libs # Fedora
```
Or extract and run:
```bash
./YourApp.AppImage --appimage-extract
./squashfs-root/AppRun
```
## License
MIT License - see [LICENSE](LICENSE)