C# Setup Helper for VS Code
Scaffold production-ready .NET Clean Architecture microservices, exception handlers, and logging handlers directly inside Visual Studio Code.
Features
Helper: Create Service
Scaffolds a full Clean Architecture microservice with interactive prompts:
- Project Template: Web API (with controllers), Console App, or Worker Service.
- .NET Version: Automatically detects installed .NET SDKs via
dotnet --list-sdks (supports .NET 8, 9, 10+).
- Database Provider: PostgreSQL, SQL Server, or In-Memory.
- Architectural Pattern:
- MediatR (CQRS Pattern): Feature-based
Get<Entity>Query merged with a FluentValidation validator and handler in a single file with XML summaries.
- Service-Repository Pattern:
Controller -> Service -> Repository -> DbContext.
- App Name: Name your microservice solution/layers.
- Naming Form: Singular or Plural folder and class naming (e.g.,
Entity/Health vs Entities/Healths).
Clean Architecture Structure (created under <workspace>/src/<AppName>/):
Domain: Entities, DTOs, repository interfaces (for the service pattern), and ServiceExtension.
Application: CQRS features (MediatR) or services, FluentValidation validators, and ServiceExtension.
Infrastructure: EF Core AppDbContext under Persistence/, repository implementations, and ServiceExtension.
API / Console / Worker: Main entry point with Program.cs wired up to AddApplication() and AddInfrastructure().
Developer Experience:
- Automatic cleanup of default template artifacts (such as
WeatherForecast).
- Generates a
.gitignore covering bin/, obj/, test results, and code-coverage files.
- Full XML documentation on all generated code.
Helper: Create Exception Handler
Scaffolds a self-contained exception handling library under src/<Name>/:
BaseException plus BadRequest, NotFound, Unauthorized, Forbidden, Conflict, TooManyRequests, and OperationCanceled exceptions.
GlobalExceptionMiddleware mapping domain exceptions and unhandled errors to structured JSON responses (snake_case).
ErrorResponseDto, SnakeCaseJsonNamingPolicy, and a ServiceExtension with UseGlobalExceptionMiddleware().
- Namespaces derived from the library name; target .NET version selectable.
Helper: Create Logging Handler
Scaffolds a Serilog-based logging library under src/<Name>/:
ICustomLogger<T> contract (in Contract/Contracts), CustomLogger<T> implementation, and AddCustomLogger() DI registration.
UseSharedRequestLogging() request-timing middleware and AddSharedLogging(serviceName) console + daily rolling-file configuration.
- Serilog packages pinned to the selected .NET major version; singular/plural naming form selectable.
Helper: Add Project Reference
- Lists every
.csproj in the workspace.
- Pick a source project, then multi-select one or more target projects to reference.
- Skips references that already exist.
Requirements
- .NET SDK (8.0, 9.0, or 10.0+) installed and available in your system PATH.
- Visual Studio Code.
Usage
- Open the Command Palette (
Ctrl+Shift+P or Cmd+Shift+P).
- Run one of the Helper commands:
- Helper: Create Service
- Helper: Create Exception Handler
- Helper: Create Logging Handler
- Helper: Add Project Reference
- Follow the interactive prompts.
Release Notes
See CHANGELOG.md for a detailed list of changes.
| |