The repository contains a set of opinionated dotnet new templates. I am happy to receive critique/feedback on the existing templates, so feel free to open issues.
These templates require .NET 9.0 SDK or later.
Use dotnet new install to install the templates.
> dotnet new install BenjaminMichaelis.Dotnet.Templates
To then use a template, navigate to a directory where you want to use the template and use the command
> dotnet new bmichaelis.{templatename}
with templatename being a name of one of the included templates listed below. Ex: dotnet new bmichaelis.nuget
If you have previously installed the templates and want to install the latest version, you can use dotnet new update to update your installed templates.
> dotnet new update
> dotnet new uninstall BenjaminMichaelis.Dotnet.Templates
Build the template package:
> dotnet pack --configuration Release -o .
Install the locally built template package
> dotnet new install . --force
You can now test the template by running:
> dotnet new bmichaelis.{templatename}
> dotnet build
> dotent test --no-build
> dotnet publish --no-build
When done, you can remove the local install of the template package by running:
> dotnet new uninstall .
- Add project under the template directory
- Update .template.config in directory
- Copy root .editorconfig to template directory (or run
./CopyEditorConfigToTemplates.ps1) - Update dependabot.yml
- Update build.yml workflow
- Add to README
Each template includes an .editorconfig file that is based on the root repository's .editorconfig. This ensures consistent coding standards across all generated projects.
For new templates:
- Copy the root
.editorconfigto your template directory - Or run
./CopyEditorConfigToTemplates.ps1to copy to all templates
For template-specific customizations:
- Templates can have their own
.editorconfigcustomizations (e.g., the NuGet template has more relaxed var usage rules) - When updating the root
.editorconfig, use theCopyEditorConfigToTemplates.ps1script which will detect and preserve existing customizations
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 the changes and run the copy script
- Create or update a PR with the template updates
- Preserve existing customizations and create backups for manual review
- Provide clear documentation of what was changed
Manual Process:
- Update the root
.editorconfigfile - Run
./CopyEditorConfigToTemplates.ps1 - Review any templates with customizations and manually merge changes if needed
- Test all templates to ensure they work correctly