TerminalResourceBuilderExtensions Methods
WithTerminal(IResourceBuilder<T>, Action<TerminalOptions>)Section titled WithTerminal(IResourceBuilder<T>, Action<TerminalOptions>)extensionIResourceBuilder<T>public static class TerminalResourceBuilderExtensions{ public static IResourceBuilder<T> WithTerminal<T>( this IResourceBuilder<T> builder, Action<TerminalOptions>? configure = null) { // ... }}Parameters
builderIResourceBuilder<T>The resource builder.configureAction<TerminalOptions>optionalAn optional callback to configure the terminal options.Returns
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1 for chaining additional configuration.Remarks
When a resource is configured with .WithTerminal(), DCP allocates a pseudo-terminal (PTY) per replica and a hidden terminal host process bridges the PTY traffic over Hex1b's HMP v1 protocol. The terminal session can be accessed from the Aspire Dashboard's terminal page or via the aspire terminal CLI command.
One terminal host process is spawned per parent replica (e.g. WithReplicas(3).WithTerminal() → 3 terminal host processes named {parent}-terminalhost-0 .. {parent}-terminalhost-2). The order of WithReplicas(...) and WithTerminal() does not matter: the per-replica hosts are materialized during BeforeStartEvent after the model is fully built, so the final replica count is always honoured.
Examples
Add terminal support to an executable resource:
var agent = builder.AddExecutable("agent", "my-agent", ".") .WithTerminal();Add terminal support with custom dimensions to a multi-replica resource. The order of WithReplicas and WithTerminal does not matter:
var agent = builder.AddExecutable("agent", "my-agent", ".") .WithReplicas(3) .WithTerminal(options => { options.Columns = 200; options.Rows = 50; });