This repository contains opinionated dotnet new templates, published as the BenjaminMichaelis.Dotnet.Templates NuGet template pack.
Feedback and contributions are welcome via issues and pull requests.
Use .NET 10 SDK or newer.
Install the template pack:
> dotnet new install BenjaminMichaelis.Dotnet.Templates
Create a project from a template:
> dotnet new bmichaelis.{template-name}
Example:
> dotnet new bmichaelis.nuget
Use the short name after bmichaelis.:
| Short name | Template docs |
|---|---|
nuget |
templates/Library/NuGet |
tool |
templates/Library/DotnetTool |
quickstart.consoleapp |
templates/Quickstart/ConsoleApp |
quickstart.benchmarkconsole |
templates/Quickstart/BenchmarkApp |
aspire.minimalapi |
templates/Aspire/MinimalApi |
> dotnet new update
> dotnet new uninstall BenjaminMichaelis.Dotnet.Templates
Build the local package:
> dotnet pack --configuration Release -o .
Install the local package:
> dotnet new install .\BenjaminMichaelis.Dotnet.Templates.*.nupkg --force
Generate and validate:
> dotnet new bmichaelis.{template-name}
> dotnet build
> dotnet test --no-build
> dotnet publish --no-build
Remove the local install:
> dotnet new uninstall .\BenjaminMichaelis.Dotnet.Templates.*.nupkg
Templates.csproj: template pack project that packstemplates/**templates/Library/NuGet:bmichaelis.nugettemplates/Library/DotnetTool:bmichaelis.tooltemplates/Quickstart/ConsoleApp:bmichaelis.quickstart.consoleapptemplates/Quickstart/BenchmarkApp:bmichaelis.quickstart.benchmarkconsoletemplates/Aspire/MinimalApi:bmichaelis.aspire.minimalapi
- Add the template files under
templates/ - Add or update
.template.config/template.json - Copy the root
.editorconfigto the template (or run.\CopyEditorConfigToTemplates.ps1) - Ensure template CI includes strict
dotnet formatchecks (whitespace, style, analyzers) - Update CI reusable workflow inputs/matrix JSON (in
build.ymland.github/workflows/template-validation.yml) - Update this README with the new template
Templates include .editorconfig files based on the root .editorconfig for consistent defaults.
CI enforces formatting via strict checks:
dotnet format whitespace <target> --verify-no-changes --no-restoredotnet format style <target> --verify-no-changes --no-restore --severity infodotnet format analyzers <target> --verify-no-changes --no-restore --severity info
CI architecture is intentionally DRY and schema-driven:
build.ymlorchestrates package build, dynamic matrix generation, and top-level test gates.github/scripts/Get-TemplateCiMatrix.ps1discovers template options fromtemplate.json, validates against the template schema, and emits workflow matrices.github/workflows/template-validation.ymlis the reusable workflow for standard template validation variants.github/actions/setup-template-testand.github/actions/trx-playlistprovide reusable native GitHub Actions setup and test-result handling
For template-specific customizations:
- Keep template-specific rules in
templates/<Template>/.template.config/editorconfig.override - Override files are authoring metadata only; generated projects still contain a single final
.editorconfig - The NuGet template uses this pattern for its relaxed style severity and namespace preferences
When updating root .editorconfig:
Automated Process (Recommended):
- Simply update the root
.editorconfigfile and push to main - The
update-template-editorconfigGitHub Actions workflow will automatically:- Detect root or override changes and run the copy script
- Create or update a PR with the template updates
- Compose each template
.editorconfigfrom root baseline + optional override - Provide clear documentation of what was changed
Manual Process:
- Update the root
.editorconfigfile - If a template needs custom rules, edit
.template.config/editorconfig.overridefor that template - Run
./CopyEditorConfigToTemplates.ps1(rerun this script after any override edits) - Test all templates to ensure they work correctly