CCSWE.Avalonia.Hosting.Desktop
12.2.2
dotnet add package CCSWE.Avalonia.Hosting.Desktop --version 12.2.2
NuGet\Install-Package CCSWE.Avalonia.Hosting.Desktop -Version 12.2.2
<PackageReference Include="CCSWE.Avalonia.Hosting.Desktop" Version="12.2.2" />
<PackageVersion Include="CCSWE.Avalonia.Hosting.Desktop" Version="12.2.2" />
<PackageReference Include="CCSWE.Avalonia.Hosting.Desktop" />
paket add CCSWE.Avalonia.Hosting.Desktop --version 12.2.2
#r "nuget: CCSWE.Avalonia.Hosting.Desktop, 12.2.2"
#:package CCSWE.Avalonia.Hosting.Desktop@12.2.2
#addin nuget:?package=CCSWE.Avalonia.Hosting.Desktop&version=12.2.2
#tool nuget:?package=CCSWE.Avalonia.Hosting.Desktop&version=12.2.2
CCSWE.Avalonia.Hosting.Desktop
Bootstrap an Avalonia classic-desktop app (Windows, Linux, macOS) on the .NET Generic Host — DI, hosted-service lifecycle, configuration, and logging — without the hand-written Avalonia-to-host plumbing.
[STAThread]
public static void Main(string[] args)
{
var builder = DesktopApplication.CreateBuilder<App>(args);
builder.Services.AddSingleton<IMyService, MyService>();
builder.Services.AddHostedService<MyBackgroundWorker>();
builder.Build().Run(args);
}
// The Avalonia XAML previewer needs a parameterless AppBuilder-returning method.
public static AppBuilder BuildAvaloniaApp() => DesktopApplication.ConfigureAppBuilder<App>();
Run() starts the hosted services, runs the Avalonia main loop, and stops the host on exit (cancelling
background services). When the host stops while the UI runs — Ctrl+C or SIGTERM, IHostApplicationLifetime.StopApplication(), or a
BackgroundService that throws (the default BackgroundServiceExceptionBehavior.StopHost; set it to Ignore to keep
the app running) — Run() closes the UI with a forced shutdown. DesktopApplicationOptions.SuppressStatusMessages
(default true) hides the console lifetime's "Press Ctrl+C to shut down." status lines. Reference Avalonia.Desktop
at the same version as Avalonia; Avalonia's platform packages aren't compatible across versions. Your App implements IServiceProviderAccessor (from CCSWE.Avalonia.Hosting) to receive
the built provider before OnFrameworkInitializationCompleted. All types share the CCSWE.Avalonia.Hosting
namespace, so a single using CCSWE.Avalonia.Hosting; is all you need.
See the repository for full usage.
MIT © Cory Charlton / CCSWE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Avalonia.Desktop (>= 12.1.0 && < 13.0.0)
- CCSWE.Avalonia.Hosting (>= 12.2.2)
- Microsoft.Extensions.Hosting (>= 10.0.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 12.2.2 | 83 | 11/23/2026 |
| 12.2.1 | 80 | 11/22/2026 |
| 12.1.27 | 65 | 11/22/2026 |
| 12.1.26 | 71 | 11/22/2026 |
| 12.1.23 | 236 | 11/16/2026 |
| 12.1.22 | 155 | 11/9/2026 |
| 12.1.21 | 150 | 10/26/2026 |
| 12.1.19 | 109 | 10/26/2026 |
| 12.1.17 | 146 | 10/19/2026 |
| 12.1.16 | 135 | 10/13/2026 |
| 12.1.14 | 151 | 10/11/2026 |
| 12.1.12 | 145 | 10/8/2026 |
| 12.1.10 | 111 | 10/8/2026 |
| 12.1.4 | 361 | 8/1/2026 |
| 12.1.3 | 157 | 8/1/2026 |
| 12.1.2 | 147 | 8/1/2026 |
| 12.1.1 | 158 | 8/1/2026 |
| 12.0.9 | 164 | 8/1/2026 |
| 12.0.8 | 167 | 8/1/2026 |
| 12.0.7 | 273 | 6/23/2026 |