Lemon.Hosting.AvaloniauiDesktop 1.0.0

dotnet add package Lemon.Hosting.AvaloniauiDesktop --version 1.0.0                
NuGet\Install-Package Lemon.Hosting.AvaloniauiDesktop -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Lemon.Hosting.AvaloniauiDesktop" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Lemon.Hosting.AvaloniauiDesktop --version 1.0.0                
#r "nuget: Lemon.Hosting.AvaloniauiDesktop, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Lemon.Hosting.AvaloniauiDesktop as a Cake Addin
#addin nuget:?package=Lemon.Hosting.AvaloniauiDesktop&version=1.0.0

// Install Lemon.Hosting.AvaloniauiDesktop as a Cake Tool
#tool nuget:?package=Lemon.Hosting.AvaloniauiDesktop&version=1.0.0                

Hosting.Avaloniaui

.NET Generic Host support for Avaloniaui app

Examples:

internal sealed class Program
{
    [STAThread]
    [SupportedOSPlatform("windows")]
    [SupportedOSPlatform("linux")]
    [SupportedOSPlatform("macos")]
    [RequiresDynamicCode("Calls Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder()")]
    public static void Main(string[] args)
    {
        var hostBuilder = Host.CreateApplicationBuilder();

        // config IConfiguration
        hostBuilder.Configuration
            .AddCommandLine(args)
            .AddEnvironmentVariables()
            .AddInMemoryCollection();

        // config ILogger
        hostBuilder.Services.AddLogging(builder => builder.AddConsole());
        // add some services
        hostBuilder.Services.AddSingleton<ISomeService, SomeService>();

        #region app default
        RunAppDefault(hostBuilder, args);
        #endregion

        #region app without mainwindow
        //RunAppWithoutMainWindow(hostBuilder, args);
        #endregion

        #region app with serviceprovider
        //RunAppWithServiceProvider(hostBuilder, args);
        #endregion
    }

    public static AppBuilder ConfigAvaloniaAppBuilder(AppBuilder appBuilder)
    {
        return appBuilder
                    .UsePlatformDetect()
                    .WithInterFont()
                    .LogToTrace()
                    .UseReactiveUI();
    }

    [SupportedOSPlatform("windows")]
    [SupportedOSPlatform("linux")]
    [SupportedOSPlatform("macos")]
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    private static void RunAppDefault(HostApplicationBuilder hostBuilder, string[] args)
    {
        hostBuilder.Services.AddAvaloniauiDesktopApplication<AppDefault>(ConfigAvaloniaAppBuilder);
        // build host
        var appHost = hostBuilder.Build();
        // run app
        appHost.RunAvaloniauiApplication(args);
    }

    [SupportedOSPlatform("windows")]
    [SupportedOSPlatform("linux")]
    [SupportedOSPlatform("macos")]
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    private static void RunAppWithoutMainWindow(HostApplicationBuilder hostBuilder, string[] args)
    {
        // add avaloniaui application and config AppBuilder
        hostBuilder.Services.AddAvaloniauiDesktopApplication<AppWithoutMainWindow>(ConfigAvaloniaAppBuilder);
        // add MainWindow & MainWindowViewModelWithParams
        hostBuilder.Services.AddMainWindow<MainWindow, MainWindowViewModelWithParams>();
        // build host
        var appHost = hostBuilder.Build();
        // run app
        appHost.RunAvaloniauiApplication<MainWindow>(args);
    }

    [SupportedOSPlatform("windows")]
    [SupportedOSPlatform("linux")]
    [SupportedOSPlatform("macos")]
    [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
    private static void RunAppWithServiceProvider(HostApplicationBuilder hostBuilder, string[] args) 
    {
        // add avaloniaui application and config AppBuilder
        hostBuilder.Services.AddAvaloniauiDesktopApplication<AppWithServiceProvider>(ConfigAvaloniaAppBuilder);
        // add MainWindowViewModelWithParams
        hostBuilder.Services.AddSingleton<MainWindowViewModelWithParams>();
        // build host
        var appHost = hostBuilder.Build();
        // run app
        appHost.RunAvaloniauiApplication(args);
    }
}

References: Nito.Host.Wpf

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 144 7/31/2024