Skip to content

Conversation

Copy link

Copilot AI commented Dec 12, 2025

Adds Avalonia 11 UI framework support following the established WPF/WinForms pattern. Enables cross-platform desktop applications with full generic host integration (DI, logging, lifecycle).

Core Library (Dapplo.Microsoft.Extensions.Hosting.Avalonia)

  • Interfaces: IAvaloniaBuilder, IAvaloniaContext, IAvaloniaService, IAvaloniaShell
  • Implementation: AvaloniaHostedService, AvaloniaThread (STA thread management), internal builders/contexts
  • Extensions: ConfigureAvalonia(), UseAvaloniaLifetime() for both IHostBuilder and IHostApplicationBuilder
  • Targets: net472, net8.0, net9.0

Usage

var host = new HostBuilder()
    .ConfigureAvalonia(avaloniaBuilder =>
    {
        avaloniaBuilder.UseApplication<App>();
        avaloniaBuilder.UseWindow<MainWindow>();
        
        // Optional AppBuilder configuration
        avaloniaBuilder.ConfigureAppBuilder(appBuilder =>
        {
            appBuilder.UsePlatformDetect().LogToTrace();
        });
    })
    .UseAvaloniaLifetime()
    .Build();

await host.RunAsync();

Windows implement IAvaloniaShell and receive DI-injected dependencies via constructor. Application lifetime tied to host lifetime via ClassicDesktopStyleApplicationLifetime.

Additional Components

  • Sample: Dapplo.Hosting.Sample.AvaloniaDemo - working demo with MainWindow, App, and ViewLocator
  • Template: dotnet new avaloniahost - project scaffolding template with nuspec
  • Docs: README updated with usage examples and template installation

Supports multiple windows, custom applications, and optional ViewLocator for MVVM. All dependencies scanned - no vulnerabilities.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • av-build-tel-api-v1.avaloniaui.net
    • Triggering command: /usr/share/dotnet/dotnet dotnet exec --runtimeconfig /home/REDACTED/.nuget/packages/avalonia.buildservices/0.0.29/tools/netstandard2.0/runtimeconfig.json /home/REDACTED/.nuget/packages/avalonia.buildservices/0.0.29/tools/netstandard2.0/Avalonia.BuildServices.Collector.dll (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Try to add Avalonia</issue_title>
<issue_description>I would like to have a similar experience as there already is for WinUI, WPF and WinForms with Avalonia 11.
This was also discussed on: AvaloniaUI/Avalonia#5241

So create Dapplo.Microsoft.Extensions.Hosting.Avalonia
For this use the Avalonia AppBuilder and allow the application using this framework to configure it's own.
Consider StartWithClassicDesktopLifetime, provide an optional default viewlocator.

Make sure there is a sample project, called Dapplo.Hosting.Sample.AvaloniaDemo and provide a template called Dapplo.Microsoft.Extensions.Hosting.Avalonia.Template with nuspec to generate a project with dotnet new.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Add Avalonia hosting with sample project Add Avalonia 11 support with generic host integration Dec 12, 2025
Copilot AI requested a review from Lakritzator December 12, 2025 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Try to add Avalonia

3 participants