DotnetPackaging helps you turn the publish output of a .NET application into Linux-friendly deliverables. The repository produces two related artifacts:
- NuGet libraries (
DotnetPackaging,DotnetPackaging.AppImage,DotnetPackaging.Deb) that expose the packaging primitives for tool authors and CI integrations. - A global
dotnettool (dotnetpackager) that wraps those libraries with a scriptable command line experience.
Both flavors share the same code paths, so whatever works in the CLI is also available from your own automation.
src/DotnetPackaging: core abstractions such as metadata models, ELF inspection, icon discovery and option builders.src/DotnetPackaging.AppImage: AppImage-specific logic, including AppDir builders and runtime composition.src/DotnetPackaging.Deb: helpers to produce Debian control/data archives and emit.debfiles.src/DotnetPackaging.Tool: thedotnetpackagerCLI that consumes the libraries.src/DotnetPackaging.DeployerToolandsrc/DotnetPackaging.Deployment: optional utilities for publishing packages from CI setups.
All projects target .NET 8.
Every library works with the Zafiro filesystem abstractions so you can build packages from real directories or in-memory containers. The helpers infer reasonable defaults (architecture, executable, icon files, metadata) while still letting you override everything.
Key capabilities:
- Build an AppImage straight from a published directory: no temporary copies, the directory is streamed into the SquashFS runtime.
- Generate intermediate AppDir structures if you want to tweak the contents before producing the final AppImage.
- Automatically detect the main executable (ELF inspection) and common icon files, with opt-in overrides.
using DotnetPackaging.AppImage;
using DotnetPackaging.AppImage.Metadata;
using Zafiro.DivineBytes;
using Zafiro.FileSystem.Core;
using Zafiro.FileSystem.Local;
var publishDir = new Directory(new FileSystem().DirectoryInfo.New("./bin/Release/net8.0/linux-x64/publish"));
var appRoot = (await publishDir.ToDirectory()).Value;
var container = new DirectoryContainer(appRoot);
var metadata = new AppImageMetadata("com.example.myapp", "My App", "my-app")
{
Version = "1.0.0",
Summary = "Cross-platform sample",
Comment = "Longer description shown in desktop menus",
};
var factory = new AppImageFactory();
var appImage = await factory.Create(container.AsRoot(), metadata);
if (appImage.IsSuccess)
{
await appImage.Value.ToByteSource()
.Bind(bytes => bytes.WriteTo("./artifacts/MyApp.appimage"));
}You can also call factory.BuildAppDir(...) to materialise an AppDir on disk, or factory.CreateFromAppDir(...) when you already have an AppDir layout.
Key capabilities:
- Build
.debarchives from any container or directory that resembles the install root of your app. - Auto-detect the executable and architecture (with
FromDirectoryOptionsoverrides when you know better). - Emit
IDatastreams so you can persist packages to disk, upload them elsewhere, or plug them into other pipelines.
using System.IO.Abstractions;
using DotnetPackaging.Deb;
using DotnetPackaging;
using Zafiro.DivineBytes;
using Zafiro.DivineBytes.System.IO;
var publishDir = new DirectoryContainer(new FileSystem().DirectoryInfo.New("./bin/Release/net8.0/linux-x64/publish"));
var debResult = await DebFile.From()
.Container(publishDir.AsRoot(), publishDir.Name)
.Configure(options =>
{
options.WithName("My App")
.WithPackage("my-app")
.WithVersion("1.0.0")
.WithSummary("Cross-platform sample app");
})
.Build();
if (debResult.IsSuccess)
{
await debResult.Value.ToData().DumpTo("./artifacts/MyApp_1.0.0_amd64.deb");
}FromDirectoryOptions exposes many more helpers (WithExecutableName, WithIcon, WithHomepage, WithCategories, WithMaintainer, etc.) so you can describe the package metadata you need.
Key capabilities:
- Generate a Flatpak layout (metadata + files/) without external tools.
- Bundle to a single
.flatpakusing the systemflatpakif available (fallback to an internal OSTree-based bundler). - Defaults-first: autodetect executable, architecture and icons; sane permissions and org.freedesktop runtime (24.08) by default.
Library (defaults-first):
using DotnetPackaging.Flatpak;
using Zafiro.DivineBytes;
using Zafiro.FileSystem.Local;
var fs = new System.IO.Abstractions.FileSystem();
var container = new DirectoryContainer(fs.DirectoryInfo.New("./bin/Release/net8.0/linux-x64/publish"));
var packer = new FlatpakPacker();
// Plan with sensible defaults (derives AppId, Name, icons, etc.)
var plan = await packer.Plan(container.AsRoot());
// Bundle: prefers system flatpak (build-export/build-bundle), falls back to internal bundler
var bytes = await packer.Bundle(container.AsRoot());
if (bytes.IsSuccess)
{
await bytes.Value.WriteTo("./artifacts/MyApp.flatpak");
}The CLI is published as DotnetPackaging.Tool and installs a dotnetpackager command that mirrors the library APIs.
dotnet tool install --global DotnetPackaging.Tooldotnetpackager deb– build a Debian/Ubuntu.debout of a publish directory.dotnetpackager appimage– build an.AppImagefile directly from a publish directory.dotnetpackager appimage appdir– generate an AppDir folder structure for inspection/customisation.dotnetpackager appimage from-appdir– package an existing AppDir into an AppImage.dotnetpackager flatpak layout– create a Flatpak layout (metadata + files/) from a publish directory.dotnetpackager flatpak bundle– create a.flatpak(uses systemflatpakby default;--systemto force system; internal fallback).dotnetpackager flatpak repo– generate an OSTree repo directory (debug/validation).dotnetpackager flatpak pack– minimal UX: only--directoryand--output-dir; auto-named output and sensible defaults.
Run dotnetpackager <command> --help to see the full list of shared options (--application-name, --comment, --homepage, --keywords, --icon, --is-terminal, etc.).
Flatpak (minimal):
dotnetpackager flatpak pack \
--directory ./bin/Release/net8.0/linux-x64/publish \
--output-dir ./artifacts
# Produces ./artifacts/<appId>_<version>_<arch>.flatpakFlatpak (full control):
dotnetpackager flatpak bundle \
--directory ./bin/Release/net8.0/linux-x64/publish \
--output ./artifacts/MyApp.flatpak \
--system \
--application-name "My App" \
--summary "Cross-platform sample"Build an AppImage in one go:
dotnetpackager appimage \
--directory ./bin/Release/net8.0/linux-x64/publish \
--output ./artifacts/MyApp.appimage \
--application-name "My App" \
--summary "Cross-platform sample" \
--homepage https://example.comStage an AppDir and inspect it before packaging:
dotnetpackager appimage appdir \
--directory ./bin/Release/net8.0/linux-x64/publish \
--output-dir ./artifacts/MyApp.AppDir
# ...modify the AppDir contents if needed...
dotnetpackager appimage from-appdir \
--directory ./artifacts/MyApp.AppDir \
--output ./artifacts/MyApp.appimageProduce a Debian package with a custom name and version:
dotnetpackager deb \
--directory ./bin/Release/net8.0/linux-x64/publish \
--output ./artifacts/MyApp_1.0.0_amd64.deb \
--application-name "My App" \
--summary "Cross-platform sample" \
--comment "Longer description" \
--homepage https://example.com \
--license MIT \
--version 1.0.0All commands work on Windows, macOS or Linux, but the produced artifacts target Linux desktops.
- Use the solution
DotnetPackaging.slnand .NET SDK 8.0 or later. - Unit tests live under
test/(AppImage, Deb, Msix, etc.). DotnetPackaging.DeployerToolautomates publishing NuGet packages and GitHub releases; seeazure-pipelines.ymlfor a full CI example.
The entire project is distributed under the MIT License. See LICENSE for details.