microsoft/aspire · error · NonInteractiveException
template
Error message
template
What it means
In non-interactive environments, NewCommand cannot prompt for a template. Instead of prompting, it displays the error and available template names and throws NonInteractiveException with the missing argument name 'template'.
Solutions
- Pass --template explicitly, e.g. 'aspire new --template aspire-starter'
- Run the command in an interactive terminal so the prompt can appear
- Pre-provision the project with a script that always supplies --template
Example fix
// before aspire new // after aspire new --template aspire-starter -n MyApp
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(template) && !console.IsInputRedirected)
{
template = await PromptForTemplateAsync(); // or fail fast with a clear message
} Try / catch
try
{
exitCode = await aspireNew.RunAsync(...);
}
catch (NonInteractiveException ex) when (ex.Message == "template")
{
Console.Error.WriteLine("Pass --template <name> when running non-interactively.");
exitCode = 1;
} Prevention
- Always pass --template in CI/non-TTY environments
- Detect non-interactive stdin before invoking aspire new
- Enumerate available templates once and pin the name in scripts
When it happens
Trigger: Running 'aspire new' (or a template-dependent new command) without --template in an environment where SupportsInteractiveInput is false (CI, non-TTY, piped stdin).
Common situations: CI pipelines or scripts running 'aspire new' without the --template flag; running inside a non-interactive shell where prompting is disabled.
Understand the failure class
Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.
Related errors
- Cannot perform destructive operation without confirmation…
- Live rendering requires interactive output.
- The option must be specified when running in…
- The option must be specified when running in…
- The value ' ' is not valid for .
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/55a53b48b79bf46e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Cli/Commands/NewCommand.cs:325
// The template subcommand was parsed successfully but the template is
// not available at runtime (e.g. .NET SDK is not installed).
InteractionService.DisplayError($"Template '{parseResult.CommandResult.Command.Name}' is not available. Ensure the required runtime is installed.");
return null;
}
var templatesForTemplateArgument = GetTemplatesForTemplateArgument(availableTemplates, parseResult);
if (templatesForTemplateArgument.Length == 0)
{
InteractionService.DisplayError("No templates are available for the current environment.");
return null;
}
if (!_hostEnvironment.SupportsInteractiveInput)
{
InteractionService.DisplayError(NewCommandStrings.NonInteractiveTemplateRequired);
var templateNames = string.Join(", ", templatesForTemplateArgument.Select(t => t.Name));
InteractionService.DisplaySubtleMessage(string.Format(CultureInfo.CurrentCulture, InteractionServiceStrings.NonInteractiveAvailableValues, templateNames));
throw new NonInteractiveException("template");
}
var templatesForPrompt = GetTemplatesForPrompt(availableTemplates, parseResult);
if (templatesForPrompt.Length == 0)
{
InteractionService.DisplayError("No templates are available for the current environment.");
return null;
}
var result = await _prompter.PromptForTemplateAsync(templatesForPrompt, cancellationToken);
return result;
}
private sealed class ResolveTemplateVersionResult
{
public string? Version { get; init; }
View on GitHub (pinned to 25830f84bd)