A small starter template for building modern .NET console applications.
This repository provides a minimal, well-structured console application that demonstrates common patterns used in production-ready tools such as dependency injection, configuration handling, environment variable loading, and console output formatting.
Use this project as a starting point when creating new .NET console applications. It includes examples of wiring up services, reading required configuration values, and writing formatted output to the console.
- Target framework:
.NET 10 - Dependency injection with
Microsoft.Extensions.DependencyInjection - Configuration support with
Microsoft.Extensions.Configuration - Helper extension
ConfigurationExtensions.GetRequiredValuethat throws a typedConfigurationExceptionwhen a required configuration key is missing - Environment variable loader (
DotEnv.Load) that reads a.envfile - Console output using
Spectre.Consolefor rich formatting - Unit tests using
NUnitandShouldly
- .NET 10 SDK
-
Clone the repository.
-
Set any required configuration values as environment variables or in a
.envfile at the project root. Example.envcontents:TEMP_FOLDER=/tmp -
Build and run the application from the
ConsoleTemplateproject directory:dotnet build dotnet run --project ConsoleTemplate/ConsoleTemplate.csprojIf a required configuration key is missing, the application will display a helpful error indicating which key is not set.
Run the unit tests from the solution root:
dotnet test
This project is intended as a simple template. Feel free to open issues or submit pull requests to improve examples or add features.