RazorDocs Search
API Reference

Aspire

Type

AspireStartupContext

Source

Provides context and helper methods during the Aspire application startup process.

Method

Resolve

IResourceBuilder<TResource> Resolve<TResource>(IAspireComponent<TResource> dependency) Source

Resolves an Aspire resource from a component, ensuring each component is only generated once.

Type Parameters

  • TResourceThe type of the resource.

Parameters

  • dependencyThe component providing the resource.

Returns

A resource builder for the resolved resource.

Method

GetPathFromRoot

string GetPathFromRoot(string relativePath) Source

Computes an absolute path from a path relative to the application root.

Parameters

  • relativePathThe relative path.

Returns

The computed absolute path.

Type

IAspireComponent<T>

Source

Indicates that the implementing class is an Aspire component that can generate resources for the application. Classes implementing this interface are responsible for generating resources of type T,

Type Parameters

  • TThe type of resource the component generates.
Method

Generate

IResourceBuilder<T> Generate(AspireStartupContext context, IDistributedApplicationBuilder appBuilder) Source

Generates and adds a resource to the Aspire distributed application builder.

Parameters

  • contextThe Aspire startup context.
  • appBuilderThe distributed application builder.

Returns

A resource builder for the generated resource.

Type

IAspireComponent

Source

The base interface for Aspire components. For now this interface does not define any members, but it serves as a marker interface to identify classes that are Aspire components. This allows for future expansion and additional functionality to be added to all Aspire components if needed.

Type

AspireProfile

Source

A base class for defining an Aspire profile as a CLI command.

Method

GetDependencies

IEnumerable<AspireProfile> GetDependencies() Source

Gets the dependencies (other profiles) that this profile requires.

Returns

An enumerable of dependent profiles.

Method

GetComponents

IEnumerable<IAspireComponent> GetComponents() Source

Gets the Aspire components that compose this profile.

Returns

An enumerable of Aspire components.

Property

PassThroughArgs

string[] PassThroughArgs { get; } Source

Gets the command-line arguments to pass through to the Aspire host.

Type

AspireApp

Source

Entry point for running an Aspire application with no specific root module.

Remarks

Use AspireApp.RunAsync(string[]) when the AppHost should use the framework-default NoHostModule and discover Aspire components from the calling assembly. If the caller has a concrete root module type that should participate in compile-time dependency and configuration registration, prefer AspireApp{TModule}.RunAsync(string[]) instead.

Method

RunAsync

Task RunAsync(string[] args) Source

Runs the Aspire application asynchronously.

Parameters

  • argsCommand-line arguments.

Returns

A task representing the run operation.

Type

AspireApp<TModule>

Source

Entry point for running an Aspire application with a specific root module.

Type Parameters

  • TModuleThe type of the root module.

Remarks

Use AspireApp{TModule}.RunAsync(string[]) when the root module is known at compile time and should participate in AppSurface dependency discovery, configuration registration, and host hooks. The new() constraint means TModule is activated by parameterless constructor rather than dependency injection, so keep constructors cheap, deterministic, and free of external side effects. Use AspireApp.RunAsync(string[]) when no root module is needed or module selection is driven by framework defaults. The call delegates to AspireAppStartup{TModule} for host activation.

Method

RunAsync

Task RunAsync(string[] args) Source

Runs the Aspire application asynchronously with the specified root module.

Parameters

  • argsCommand-line arguments.

Returns

A task representing the run operation.

Type

AspireAppStartup<TModule>

Source

Starts an Aspire AppHost with an AppSurface root module that implements IAppSurfaceHostModule.

Type Parameters

  • TModuleThe root AppSurface host module type for the Aspire AppHost.

Remarks

AspireAppStartup{TModule} is the Aspire-specific bootstrapper behind AspireApp{TModule}.RunAsync(string[]). The new() constraint activates the root module with a parameterless constructor before dependency injection is available, so module constructors should avoid service resolution, blocking work, and disposable ownership. Host-module service registrations run through ConsoleStartup{TModule} before ConfigureAdditionalServices discovers Aspire components.

Method

ConfigureAdditionalServices

void ConfigureAdditionalServices(StartupContext context, IServiceCollection services) Source

Discovers IAspireComponent types from the entry assembly and registers each concrete type as a singleton.

Parameters

  • contextThe AppSurface startup context that supplies the entry assembly to scan.
  • servicesThe service collection receiving discovered Aspire component registrations.

Remarks

ConfigureAdditionalServices runs after the root IAppSurfaceHostModule and dependency modules have registered services. Components are registered by concrete type only, not by implemented interfaces, so consumers should resolve concrete component types directly. The registration is startup-only and does not transfer disposal ownership beyond normal container ownership.