IDeploymentTarget Target { get; }
Source
Gets the provider target.
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
,
T
IResourceBuilder<T> Generate(AspireStartupContext context, IDistributedApplicationBuilder appBuilder)
Generates and adds a resource to the Aspire distributed application builder.
context
appBuilder
A resource builder for the generated resource.
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.
Entry point for running an Aspire application with no specific root module.
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.
Task RunAsync(string[] args)
Runs the Aspire application asynchronously.
args
A task representing the run operation.
Entry point for running an Aspire application with a specific root module.
TModule
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.
Task RunAsync(string[] args)
Runs the Aspire application asynchronously with the specified root module.
args
A task representing the run operation.
Represents one artifact-only deployment target in the evaluated Aspire resource graph.
The resource has no runtime lifetime or endpoint. It carries provider inputs and a per-pipeline render cache.
ReferenceExpression GetHostAddressExpression(EndpointReference endpointReference)
Rejects endpoint projection because artifact-only targets do not expose deployed addresses.
IDeploymentTarget Target { get; }
Source
Gets the provider target.
ParameterResource BindingProfile { get; }
Source
Gets the non-secret binding-profile parameter.
ParameterResource SourceRevision { get; }
Source
Gets the non-secret source-revision parameter.
string AppHostDirectory { get; }
Source
Gets the trusted AppHost directory.
string EnvironmentName { get; }
Source
Gets the Aspire-selected environment name.
DeploymentRenderResult? LastRenderResult { get; set; }
Source
Gets or sets the render result produced by the publish dependency in the current pipeline process.
Verification reuses this value only after its declared publish dependency completes; a new AppHost process starts without cached evidence.
Immutable Aspire annotation projected into one provider-neutral migration-job intent.
ResourceName
Phase
Image
Command
Arguments
Execution
ConnectionSecret
ConfigurationKey
RequirePrivateNetwork
Isolates the repository-pinned Aspire 13.4.4 experimental deployment-pipeline API.
void Register(IResourceBuilder<IComputeEnvironmentResource> builder, AppSurfaceDeploymentTargetResource resource)
Registers publish and verification factories with their native Aspire dependency relationships.
builder
resource
Task<DeploymentIntent> BuildIntentAsync(AppSurfaceDeploymentTargetResource targetResource, DistributedApplicationModel model, CancellationToken cancellationToken)
Projects explicitly annotated resources assigned to one target into canonical neutral intent.
targetResource
model
cancellationToken
Validated, sorted deployment intent.
Task CompletePublishAsync(AppSurfaceDeploymentTargetResource resource, DeploymentRenderResult result, Action<string, string> addSummary, IReportingStep reportingStep, CancellationToken cancellationToken)
Reports publish evidence and the no-mutation assurance through Aspire.
Task VerifyRenderedAsync(AppSurfaceDeploymentTargetResource resource, DeploymentRenderResult renderResult, Action<string, string> addSummary, IReportingStep reportingStep, CancellationToken cancellationToken)
Runs shadow parity verification and reports a read-only success or typed failure.
Task<DeploymentRenderResult> RenderAndWriteAsync(AppSurfaceDeploymentTargetResource resource, DistributedApplicationModel model, IServiceProvider services, CancellationToken cancellationToken)
Builds intent, confines the profile, invokes the pure provider renderer, and atomically writes one complete bundle.
The provider result plus any adapter-owned neutral-intent artifact.
string ResolveBindingProfilePath(string appHostDirectory, string bindingProfilePath)
Resolves a relative profile path lexically beneath the trusted AppHost directory.
The provider loader performs the filesystem-level symbolic-link check before reading.
Observes resources acquired by one configured profile activation before an unstarted host is returned.
Install this forwarding builder before Generic Host defaults and module callbacks. It preserves the selected service-provider object and container type. Its singleton IHost factory receives an idempotent host lease to prevent DI-driven disposal re-entry without wrapping the selected service provider. Configuration sources are decorated only after all configuration callbacks, so callbacks retain their original source collection. Providers and reload registrations returned during framework construction receive shared, idempotent disposal leases: nested roots, failed root construction, detached host configuration and secondary disposal failures cannot cause duplicate leaf disposal. A custom source or service-provider factory owns allocations it does not return; roots explicitly built inside user callbacks remain caller-owned. After Build returns, host-owned files and services are disposed through the host, while the guard retains detached configuration ownership. No hosted service is started by this builder.
IHostBuilder ConfigureDefaults(string[] args)
Applies the same Generic Host defaults as Host.CreateDefaultBuilder through the observing factory seam.
args
This builder, with default provider validation options preserved.
ValueTask DisposeAsync()
Joins idempotent asynchronous cleanup, preferring asynchronous host/provider/file disposal when supported.
A value task that completes after every acquired ownership lease has been attempted.
A shared completion is published under the ownership lock before cleanup starts outside that lock, so user disposal code can coordinate with reload registrations on other threads. Calls from that cleanup flow return immediately; independent callers join its completion and observe the same first error. Cleanup continues after secondary errors and rethrows the first error. The activation factory suppresses these errors only when it already has a primary creation failure. Once a host exists, file/provider cleanup follows the host's disposal policy; configuration leases additionally drain detached and partially constructed trees.
Provides context and helper methods during the Aspire application startup process.
IResourceBuilder<TResource> Resolve<TResource>(IAspireComponent<TResource> dependency)
Resolves an Aspire resource from a component, ensuring each component is only generated once.
TResource
dependency
A resource builder for the resolved resource.
string GetPathFromRoot(string relativePath)
Combines the constructor's repository root with a trusted repository-relative asset path.
relativePath
A fully qualified path for repository-relative input, without checking asset existence.
ArgumentNullException
relativePath
is null, even if no root was found.InvalidOperationException
Retains Path.Combine(string, string)
semantics for empty, rooted and parent-traversal inputs; this is path computation, not containment or asset validation. A root is required even for rooted input. Callers check files/directories and own their import or mount errors. The root is never rediscovered here. See the repository asset guide
.
string? FindRepoRoot(string? appHostDirectory)
Selects the nearest Git-marked ancestor of a fully qualified AppHost directory, including the anchor itself.
appHostDirectory
The first Git file/directory ancestor's full path, or null when no usable root is available.
Marker contents are not parsed and Git validity is not checked. This single constructor-time walk performs no Git subprocess, existence requirement for the anchor, output/CWD fallback, or repeated path-time discovery. Marker paths use PathUtils.PathUnder
to keep each probe beneath its candidate directory.
A base class for defining an Aspire profile as a CLI command.
IEnumerable<AspireProfile> GetDependencies()
Gets the dependencies (other profiles) that this profile requires.
An enumerable of dependent profiles.
IEnumerable<IAspireComponent> GetComponents()
Gets the Aspire components that compose this profile.
An enumerable of Aspire components.
void Compose(IDistributedApplicationBuilder appBuilder, CancellationToken cancellationToken)
Composes this profile into an Aspire distributed application builder.
appBuilder
cancellationToken
Components from each profile returned by GetDependencies
are resolved in dependency and component enumeration order before this profile's direct GetComponents
results. Composition includes only those direct dependencies; it does not recursively traverse their dependencies. Values that do not implement IAspireComponent{TResource}
for IResource
are ignored. Cancellation is cooperative at the documented checkpoints, and cancellation or another failure does not roll back resources already added to appBuilder
.
string[] PassThroughArgs { get; }
Source
Gets the command-line arguments to pass through to the Aspire host.
Profiles default to an empty argument set so AppSurface command selection remains owned by CliFx. Override this property when a profile intentionally needs to pass known AppHost arguments into DistributedApplicationBuilder
. Unknown command-line arguments are not forwarded automatically.
Extends an Aspire resource graph with explicit AppSurface deployment intent.
IResourceBuilder<IComputeEnvironmentResource> AddAppSurfaceDeploymentTarget(this IDistributedApplicationBuilder builder, string name, IDeploymentTarget target, IResourceBuilder<ParameterResource> bindingProfile, IResourceBuilder<ParameterResource> sourceRevision)
Adds one artifact-only deployment target to the native Aspire deployment pipeline.
builder
name
target
bindingProfile
sourceRevision
The compute environment used with Aspire's WithComputeEnvironment
extension.
The publish step writes artifacts only. It does not call a cloud API, apply infrastructure, resolve secret values, execute a job, or change traffic. Verification is exposed as the separately named appsurface-gcp-verify
step, performs shadow parity for pre-cutover adoption, and is required to remain read-only. After writer cutover, the application-owned release workflow may call the provider target directly with DeploymentParityMode.Owned
.
IResourceBuilder<ProjectResource> WithAppSurfaceMigrationJob(this IResourceBuilder<ProjectResource> builder, Action<AppSurfaceMigrationJobOptions> configure)
Annotates an existing Aspire project as one explicit migration-job intent.
builder
configure
The original project builder for chaining.
This annotation never reads the connection parameter value. Assign the returned project explicitly with Aspire's WithComputeEnvironment
; unassigned annotations are rejected during publish rather than inferred. Calling this method twice for the same resource is an error.
Builds the provider-neutral intent annotation for one existing Aspire project resource.
AppSurfaceMigrationJobOptions WithImage(IResourceBuilder<ParameterResource> image)
Uses a non-secret parameter containing a full immutable container image identity.
AppSurfaceMigrationJobOptions WithPhase(DeploymentPhase phase)
Sets the deployment phase. Version 1 supports candidate preparation.
AppSurfaceMigrationJobOptions WithCommand(string command, params string[] arguments)
Sets the executable and ordered arguments without parsing a shell command line.
AppSurfaceMigrationJobOptions WithConnectionSecret(IResourceBuilder<ParameterResource> secret, string configurationKey)
Records a secret parameter by logical name without resolving its value.
secret
configurationKey
AppSurfaceMigrationJobOptions RequirePrivateNetwork()
Requires the provider target to supply private networking. Version 1 supports candidate preparation and requires every migration-job configuration to call this method; otherwise building the annotation throws ASDEPLOY207
.
AppSurfaceMigrationJobOptions WithExecutionPolicy(int tasks, int parallelism, int retries, TimeSpan timeout)
Sets explicit task, parallelism, retry, and timeout bounds.
Starts an Aspire AppHost with an AppSurface root module that implements IAppSurfaceHostModule
.
TModule
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.
void ConfigureAdditionalServices(StartupContext context, IServiceCollection services)
Discovers IAspireComponent
types from the entry assembly and registers each concrete type as a singleton.
context
services
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.
Owns the unstarted AppSurface host used to activate one typed Aspire profile.
TProfile
Construction transfers ownership of the supplied host to the lease. Callers may use Profile
and Services
only while the lease is active; profile dependencies may come from the owned service provider. Disposal is idempotent, chooses asynchronous host disposal when available, and invalidates service access. Callers must not dispose the owned host separately or use the profile after lease disposal begins.
Task DisposeHostAsync(IHost host)
Disposes a host asynchronously when its concrete implementation supports asynchronous cleanup.
host
A task that completes after host cleanup.
TProfile Profile { get; }
Source
Gets the activated profile while the lease and its constructor-injected services remain valid.
IServiceProvider Services { get; }
Source
Gets the owned activation host's service provider before disposal begins.
ObjectDisposedException
Activates Aspire profiles through the same AppSurface host composition used at runtime.
Task<AspireProfileActivationLease<TProfile>> ActivateAsync<TAppHost, TModule, TProfile>(CancellationToken cancellationToken)
Builds an unstarted AppSurface host for TAppHost
and resolves one typed Aspire profile.
TAppHost
TModule
TProfile
cancellationToken
A lease that owns the unstarted host, profile, and service provider. The caller must dispose the returned lease.
OperationCanceledException
Activation uses empty command-line arguments and pins the entry-point assembly to TAppHost
. The host is never started. If activation or cancellation prevents ownership from being returned, the method disposes the host before propagating the primary failure.
Task<AspireProfileActivationLease<TProfile>> ActivateConfiguredAsync<TAppHost, TModule, TProfile>(Action<IConfigurationBuilder>? configureConfiguration, Action<IServiceCollection>? configureServices, CancellationToken cancellationToken)
Activates a profile after final per-call configuration and services callbacks with early ownership observation.
TAppHost
TModule
TProfile
configureConfiguration
configureServices
cancellationToken
A lease owning the unstarted host and detached or partially constructed configuration.
The selected provider factory is retained, including later container precedence. Callback exceptions are preserved for the Testing factory's phase diagnostics. Cleanup and logging failures cannot replace them.
Classifies the process-fatal exception families used by Aspire profile activation and testing cleanup paths.
This deliberately narrow helper recognizes OutOfMemoryException
, StackOverflowException
, and AccessViolationException
. It is not a general exception-handling policy for AppSurface callers.
bool IsProcessFatal(Exception exception)
Determines whether an exception is an OutOfMemoryException
, StackOverflowException
, or AccessViolationException
that should propagate immediately.
exception
true
for process-fatal exception types; otherwise false
.