Skip to content

Contributing templates

This page explains how to propose, build and maintain a ConnectSoft template, or make a major change to one. It is written for architects and engineers who work on the dotnet new templates for services, gateways and Blazor and MAUI applications.

Templates are where ConnectSoft conventions enter every generated service. A defect in a template is copied into every service generated afterwards, so template changes get the most careful review.

When to create a template

Create a template when: - a new architectural shape is needed, such as an API gateway or a worker; - several projects need the same structure; - a new supported technology stack is approved.

Do not create a template for a one-off or customer-specific need. Generate from an existing template and extend the result instead.

Blazor and MAUI repositories are classified as template, concrete template or library before work starts. See Blazor and MAUI template alignment.

Decision record

Every new template needs an ADR (see Decision records). The ADR states: - the template's purpose and scope; - its dependencies on other templates, libraries and platforms; - the alternatives considered; - the consequences.

Building a template

  1. Start from the base. Service-shaped templates build on ConnectSoft.BaseTemplate through the base-template Git submodule. See Template layering and reuse.
  2. Define parameters. Give every parameter a sensible default. Blazor and MAUI templates use the standard parameter names:
  3. Framework
  4. uiKitAdapter
  5. includeTests
  6. includeSamples
  7. includeDocs
  8. UseLocalization
  9. UseObservability
  10. UseSecurity
  11. UseValidatedOptions
  12. skipRestore
  13. Wire in the cross-cutting features. These are included by default:
  14. observability: logging, tracing and metrics;
  15. security: authentication, authorization and input validation;
  16. tests: unit tests, acceptance tests and architecture tests;
  17. the pipeline, using the shared step templates (see CI/CD);
  18. documentation.
  19. Package it. Include .template.config/template.json, the CLI and IDE host files, the .nuspec, the template pipeline and a scaffold smoke test.

Changing the base template

A change in ConnectSoft.BaseTemplate reaches the templates built on it only through their base-template submodule: 1. Merge and publish the BaseTemplate change first. 2. Then update the base-template submodule reference in each dependent template, in its own pull request. 3. Regenerate and test each dependent template after the bump.

Do not edit the base-template folder inside a dependent template. That folder is a submodule checkout, and edits there are lost or end up in the wrong repository.

Validation

Before a template change is merged: - generate a sample from the changed template with dotnet new; - build the generated solution; - run its tests; - run the template pipeline.

The nightly pipeline validates every template installer again (see Nightly Template Validation Pipeline).

The validation checklist: - [ ] The template generates the expected project structure. - [ ] The generated code builds without new warnings and its tests pass. - [ ] Observability, security and test projects are present. - [ ] The pipeline is configured. - [ ] The documentation is generated.

Documentation

Each template has a page in the Templates section of this site. The page covers: - what the template generates; - the generated project structure; - the parameters with their defaults; - a quick-start command; - the known limitations.

Keep the template registry (Templates registry) current.

Maintenance and retirement

  • The template owner keeps dependencies, patterns and documentation current, following the upgrade order.
  • Templates move through the lifecycle states Draft, Experimental, Beta, Stable and Deprecated. A template is deprecated with advance notice and a migration path.