Template Smart Defaults

Applies cross-parameter default rules when creating .NET projects with dotnet new, filling gaps consistently without overriding values the user set explicitly. USE FOR: choosing sensible defaults for related parameters during project creation, resolving cross-parameter interactions (AOT implies a compatible framework, auth implies HTTPS, controllers excludes minimal-API flags), explaining why a default was applied. DO NOT USE FOR: creating the project itself (use template-instantiation), finding or comparing templates (use template-discovery and template-comparison), authoring or validating custom templates (use template-authoring and template-validation).

Workflow

  1. Gather the parameters the user has explicitly set.
  2. Apply each rule below only where the corresponding parameter is unset — never override an explicit user value.
  3. Log every applied default with a short rationale so the user can see and override it.
  4. Confirm the chosen parameter names and choices against dotnet new <template> --help before creating.

> AOT at create time vs publish time. --aot is a dotnet new flag only on the templates that expose it (e.g. console, worker, grpc); it is not on webapi/webapp. There is no --publish-aot template flag — publish-time native AOT is enabled with the MSBuild property PublishAot=true (via dotnet publish or in the .csproj), not through dotnet new. Apply the framework rule only when the template actually offers --aot.

Rules

| Rule | Default applied | Rationale | |------|-----------------|-----------| | --aot is set (on templates that support it, e.g. console/worker/grpc) and --framework is unset | Set --framework to the latest AOT-compatible framework the template offers | Native AOT requires a recent, AOT-capable target framework; using the latest avoids build failures. | | --auth is anything other than None | Do NOT pass --no-https | Authentication flows (cookies, tokens, redirects) require HTTPS; disabling it breaks auth. | | --use-controllers is set | Do NOT also pass a minimal-API flag | Controllers and minimal APIs are mutually exclusive program models; passing both is contradictory. | | User set a value explicitly | Leave it unchanged | Smart defaults only fill gaps; explicit user intent always wins. |

Related skills

Compares two or more dotnet new templates side by side to help users choose between them based on parameters, feature support, frameworks, and classifications.