Wolfgang.Template.Console.ETL-SubCommand
0.3.0
dotnet new install Wolfgang.Template.Console.ETL-SubCommand::0.3.0
ConsoleAppTemplate
A robust template for building .NET console applications with modern development best practices, including dependency injection, configuration management, logging, and extensible command-line parsing.
Table of Contents
Overview
ConsoleAppTemplate provides a solid foundation for .NET console applications. It leverages best practices such as structured logging (via Serilog), dependency injection, configuration via JSON files, and powerful command-line parsing (with McMaster.Extensions.CommandLineUtils).
This template is designed for scalability, maintainability, and ease-of-use, whether for small scripts or complex automation tools.
Features
- Command Line Parsing: Easily define commands, subcommands, and options.
- Structured Logging: Integrated Serilog with console and file sinks, plus support for enrichment.
- Dependency Injection: Built-in .NET DI with easy configuration.
- Flexible Configuration: Supports single or environment-specific JSON configuration files.
- Error Handling: Robust error catching and exit codes for integration in automation pipelines.
- Extensible: Easily add new commands, services, or configuration sections.
Getting Started
Prerequisites
- .NET 6.0 SDK or later
- (Optional) Visual Studio or VS Code
Installation
Install the template from NuGet:
dotnet new install <PackageID>
Replace
<PackageID>
with the actual NuGet package identifier for ConsoleAppTemplate.
Create a new project using this template:
dotnet new console-app-template -n MyConsoleApp
cd MyConsoleApp
Review Next Steps:
After creating your project, be sure to review the Instructions.md
file included in the root of your new project directory. This file provides detailed, project-specific setup steps and guidance for customizing your application.
If you create your project using Visual Studio, the
Instructions.md
file will open automatically to help guide you through initial configuration and customization.
Restore packages and build:
dotnet restore
dotnet build
Configuration
The template uses JSON files for application and environment configuration.
- appsettings.json: Main config file (default for all environments)
- appsettings.Development.json, appsettings.Production.json, etc.: Environment-specific files (optional)
The configuration system will load the appropriate file based on the DOTNET_ENVIRONMENT
variable.
To set the environment (example for Windows):
set DOTNET_ENVIRONMENT=Development
Or for Linux/macOS:
export DOTNET_ENVIRONMENT=Development
Usage
Run the application from the root directory:
dotnet run
You can also publish the app and run the executable:
dotnet publish -c Release
./bin/Release/net6.0/MyConsoleApp.exe [options]
Command Line Options
The template supports a main command and subcommands. To view help:
dotnet run -- --help
Add new subcommands by creating classes and registering them in Program.cs
.
Project Structure
MyConsoleApp/
├── Program.cs
├── AppSettings.json
├── AppSettings.Development.json
├── AppSettings.Production.json
├── Instructions.md
└── ...
- Program.cs: Entry point with main logic and configuration.
- AppSettings.json*: Application configuration files.
- Instructions.md: In-depth development and customization notes.
Customization
Commands and Subcommands
- Define your main command in
Program.cs
using attributes. - Add subcommands by creating new classes and registering them with
[Subcommand(typeof(MyCommand))]
.
Example:
[Subcommand(typeof(MyNewCommand))]
Configuration Files
- Single File: Use
appsettings.json
for all environments. - Per Environment: Use
appsettings.{Environment}.json
files.
See Instructions.md for detailed setup.
Logging
- Logging is configured via the
Serilog
section in yourAppSettings*.json
. - Add or remove log sinks and adjust minimum levels as needed.
- Default logs to both console and file (see
AppSettings.json
).
Contributing
Contributions are welcome! Please fork the repo and submit a pull request for improvements or bug fixes.
- Fork the repository
- Create a new branch (
git checkout -b feature/my-feature
) - Commit your changes (
git commit -am 'Add new feature'
) - Push to the branch (
git push origin feature/my-feature
) - Open a pull request
License
This project is licensed under the MIT License. See the LICENSE file for details.
References & Further Reading
- Serilog Documentation
- McMaster.Extensions.CommandLineUtils
- Microsoft.Extensions.Hosting
- .NET Generic Host
Support
For questions, please open an issue on GitHub.
For more in-depth developer notes and template usage, see [src/ConsoleAppTemplate/Content/Instructions.md](src/ConsoleAppTemplate/Content/Instructions.md).
-
.NETStandard 2.0
- System.ComponentModel.Annotations (>= 5.0.0)
- Wolfgang.Etl.Abstractions (>= 0.6.0)
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 |
---|---|---|
0.3.0 | 149 | 8/13/2025 |