Neolution.DotNet.Console 3.0.0-rc.2

Prefix Reserved
This is a prerelease version of Neolution.DotNet.Console.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Neolution.DotNet.Console --version 3.0.0-rc.2                
NuGet\Install-Package Neolution.DotNet.Console -Version 3.0.0-rc.2                
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="Neolution.DotNet.Console" Version="3.0.0-rc.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Neolution.DotNet.Console --version 3.0.0-rc.2                
#r "nuget: Neolution.DotNet.Console, 3.0.0-rc.2"                
#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 Neolution.DotNet.Console as a Cake Addin
#addin nuget:?package=Neolution.DotNet.Console&version=3.0.0-rc.2&prerelease

// Install Neolution.DotNet.Console as a Cake Tool
#tool nuget:?package=Neolution.DotNet.Console&version=3.0.0-rc.2&prerelease                

Introduction

Neolution.DotNet.Console is a versatile package designed as a launchpad for .NET console applications. It comes equipped with a built-in dependency injection setup, mirroring the functionality found in ASP.NET Core applications, thus providing a seamless and intuitive user experience.

Getting Started

To help you kickstart your console application, we've provided a a sample application that should demonstrate the basic usage of this package.

Guides

Migrate from V2 to V3

In .NET 6 the hosting model for ASP.NET Core applications was changed, we adjusted to that to fulfill the primary goal of this package: to provide a seamless and intuitive user experience. This introduces breaking changes that are explained below.

Removed ICompositionRoot interface and UseCompositionRoot extension method

The builder returned from calling DotNetConsole.CreateDefaultBuilder(args) now has a Services property that can be used to register services. Like in ASP.NET, this can now be done directly in Program.cs.

public static async Task Main(string[] args)
{
    var builder = DotNetConsole.CreateDefaultBuilder(args);

    // Register your services here...
    builder.Services.AddHttpClient();
    builder.Services.AddScoped<IScopedService, ServiceA>();
    builder.Services.AddSingleton<ISingletonService, ServiceB>();

    await builder.Build().RunAsync();
}

Async by default

All commands are now async by default. Use the new IDotNetConsoleCommand interface instead of IConsoleAppCommand and IAsyncConsoleAppCommand.

Service registration validation

The service registrations are now validated when app.Build() is called. This means that the application will not start if not all services that are registered (even if not used during runtime) can be created by the DI container or when there are scope/lifetime issues with the services.

Strict verb matching when default verb is defined

If one verb is defined as default, but the verb passed as argument is not matching any of the available verbs, the builder will no longer build a console application and instead throw an exception. This is done to avoid running the default verb command if the user accidentally uses a verb that is not available or simply made a typo.

E.g. if the app uses start as the default verb and the user intention is to start the command assigned to the verb echo but mistypes it as eccho or similar, the builder will fail with an exception. Previous versions would have run the start command, because it's defined as default verb, but it was not the intention.

Migrate from V1 to V2

V2 introduces breaking changes from V1, primarily because it upgrades NLog to Version 5. For a detailed review of these changes, please refer to the official NLog release notes.

Removed Logging section in appsettings.json

NLog decided to deprecate Microsoft's Logging section in the appsettings.json starting with V5. In accordance of that decision we've also transitioned to only using NLog rules for filtering logging output. Although these rules might be a bit more complex, they offer greater flexibility and control.

To get acquainted with these rules and learn how to migrate your current configuration, check out the NLog documentation on logging rules. There's also a guide on the new finalMinLevel attribute that you might find helpful.

Removed default logging targets

  • AWS Logger: The AWS Logger, previously used for logging to CloudWatch, has been removed due to decreased usage. If you still need it, don't worry, you can easily download it separately. The configuration remains the same.

  • DatabaseTarget: The DatabaseTarget is no longer part of the NLog NuGet package. If you use this target, you'll need to download it separately to ensure its continued functionality.

There are additional targets that have been transitioned into separate packages. Please review this list to determine if any targets you use are affected.

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 was computed.  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
3.0.4-rc.0 41 10/28/2024
3.0.3 2,281 10/9/2024
3.0.3-rc.0 53 10/8/2024
3.0.2 276 10/4/2024
3.0.2-rc.0 47 10/3/2024
3.0.1 97 10/2/2024
3.0.0-rc.3 91 9/17/2024
3.0.0-rc.2 535 9/9/2024
3.0.0-rc.1 49 9/6/2024
3.0.0-rc.0 54 8/28/2024
3.0.0-alpha.1 50 8/28/2024
3.0.0-alpha.0 48 8/27/2024
2.0.2 4,221 6/6/2024
2.0.1 104 6/6/2024
2.0.0-rc.0 4,526 8/24/2023
2.0.0-alpha.0 97 7/20/2023
1.1.0-beta0001 9,796 10/17/2022
1.0.3 68,468 6/17/2022