Skip to main content
net10.0

This package is part of the Nano Library, a set of reusable .NET libraries for building microservice applications. Nano addresses common non-business concerns such as logging, persistence, messaging, validation, and documentation, while remaining fully configurable and extensible, so applications can stay focused on business logic. See https://github.com/Nano-Core/Nano.Library for details.

Published
Apr 24, 2026
5mo ago
Total Downloads
3.4K
3,403

Install

dotnet add package Nano.App.Console --version 10.0.0-preview1
ProductVersions
.NET
net10.0

README

Nano.App.Console

Build and Deploy NuGet NuGet

Nano Console application.


Table of Contents

Summary

The NanoConsoleApplication is a ready-to-use application template for building console-based workers with Nano.
At its core, it is a standard console application that starts and executes one or more workers. When deployed to Kubernetes, it is typically configured to run as a CronJob, while in the Development environment it simply runs as a normal console application without any scheduling.

The application derives from BaseNanoApplication and implements the IApplication interface, following established Nano application patterns. It provides a concrete and opinionated implementation tailored specifically for console workloads.

NanoConsoleApplication exposes convenient static factory methods for creating and configuring the application with sensible defaults, while still allowing full customization through configuration and the ConfigureServices method. This ensures that all core application behaviors are initialized consistently from configuration, reducing boilerplate code and simplifying the creation of new console applications.

⚠️ Before proceeding, it is highly recommended to familiarize yourself generally with Nano Applications.

Registration

First install the Nano.App.Console NuGet package.

dotnet add package Nano.App.Console;

Then, to create a NanoConsoleApplication simply add the following code to program.cs.

NanoConsoleApplication
    .ConfigureApp()
    .ConfigureServices(x =>
    {
        // Your services...
    })
    .Build()
    .Run();

Register your custom services in the ConfigureServices(x => { }) method to extend Nano with additional functionality or integrations.

Configuration

The App section in the configuration defines behavior related to the application.

Setting Type Default Description
Version string 1.0.0.0 Application version identifier.
Localization object null Localization configuration options. See Localization.
Apis dictionary [] Named Nano API client configurations available to the application. See Api-Client.
"App": 
{
  "Version": "1.0.0.0",
  "Localization": null,
  "Apis": null
}

đź“– Learn more about Application Configuration here.

Localization

The Nano configuration supports specifying a default CultureInfo for console applications, ensuring that culture-sensitive operations such as date, number, and currency formatting—are applied consistently across the entire application lifecycle.

The DefaultCultureInfo will be set to the configured default culture.

Setting Type Default Description
DefaultCulture string en-US The default culture used by the application.
"Localization": {
  "DefaultCulture": "en-US"
}

Exception Handling

Exceptions thrown by individual Nano workers are handled internally, ensuring that failures in one worker do not impact the execution of others.

When a Logging Provider is registered, any worker that fails will automatically log the exception.

No additional configuration or setup is required.

Try it out yourself using the Api.ExceptionHandling example.

Api Clients

Nano API clients provide a consistent and structured way for applications to communicate with other Nano API services.

In console applications, they allow worker processes to establish connections with one or more Nano API applications, send requests, and retrieve responses in a reliable and predictable manner. This enables console workers to leverage the functionality of multiple Nano services while keeping service boundaries clear and maintaining consistent error handling, logging, and response propagation across the system.

đź“– Learn more Nano Api Clients

Console Workers

You can implement as many workers as you need by creating classes that implement IWorker.
All registered workers will run automatically when the application starts, and the application will shut down once all workers have completed their execution.

For convenience, derive your worker from BaseWorker. This allows you to only implement OnStartAsync() if you don't need any custom logic in OnStopAsync().

public class MyWorker(ILogger logger) 
    : BaseWorker(logger)
{
    public override async Task OnStartAsync(CancellationToken cancellationToken = default)
    {
        // Your startup logic here...
    }

    // Optional
    public override async Task OnStopAsync(CancellationToken cancellationToken = default)
    {
        // Your shutdown/cleanup logic here...
    }
}

You can inject any registered service your worker needs, including scoped services, which will be correctly resolved when the worker is executed.

Try it out yourself using the Console.Workers example.

Startup Tasks

Nano Console applications supports start-up tasks that execute before the application begins processing requests.
The console worker won't start until all configured start-up tasks have completed successfully.

While start-up tasks are rarely required for console applications, this feature is available to ensure any necessary initialization can be performed before the worker starts.

đź“– Learn more Nano Startup Tasks.

Try it out yourself using the Api.StartupTasks example.

Adoption Assessment

Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.

This version is marked prerelease. Validate its API and upgrade path before production use.Compatibility metadata lists 1 target framework; confirm the exact target used by your application.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.