Skip to content
Docs Try Aspire

IDistributedApplicationBuilder Properties

Interface Properties 11 members
A builder for creating instances of DistributedApplication.
AppHostAssembly Section titled AppHostAssembly abstractnullable Assembly?
Assembly of the app host project.
public abstract Assembly? AppHostAssembly { get; }
AppHostDirectory Section titled AppHostDirectory abstract string
Directory of the project where the app host is located. Defaults to the content root if there's no project.
public abstract string AppHostDirectory { get; }
Configuration Section titled Configuration abstract ConfigurationManager
Gets the set of key/value configuration properties.
public abstract ConfigurationManager Configuration { get; }
This can be mutated by adding more configuration sources, which will update its current view.
Environment Section titled Environment abstract IHostEnvironment
Gets the information about the hosting environment an application is running in.
public abstract IHostEnvironment Environment { get; }
Eventing infrastructure for AppHost lifecycle.
public abstract IDistributedApplicationEventing Eventing { get; }
Execution context for this invocation of the AppHost.
public abstract DistributedApplicationExecutionContext ExecutionContext { get; }

The IDistributedApplicationBuilder.ExecutionContext property provides access key information about the context in which the distributed application is running. The most important properties that the DistributedApplicationExecutionContext provides is the DistributedApplicationExecutionContext.IsPublishMode and DistributedApplicationExecutionContext.IsRunMode properties. Developers building .NET Aspire based applications may whish to change the application model depending on whether they are running locally, or whether they are publishing to the cloud.

An example of using the DistributedApplicationExecutionContext.IsRunMode property on the IDistributedApplicationBuilder via the IResourceBuilder`1.ApplicationBuilder. In this case an extension method is used to generate a stable node name for RabbitMQ for local development runs.

private static IResourceBuilder<RabbitMQServerResource> RunWithStableNodeName(
this IResourceBuilder<RabbitMQServerResource> builder)
{
if (builder.ApplicationBuilder.ExecutionContext.IsRunMode)
{
builder.WithEnvironment(context =>
{
// Set a stable node name so queue storage is consistent between sessions
var nodeName = $"{builder.Resource.Name}@localhost";
context.EnvironmentVariables["RABBITMQ_NODENAME"] = nodeName;
});
}
return builder;
}
Gets the service for managing Aspire file system operations.
public virtual IFileSystemService FileSystemService { get; }

The IDistributedApplicationBuilder.FileSystemService provides a centralized way to manage temporary files and directories used by Aspire, enabling testability and consistent temp file management.

Resources and infrastructure code should use this service instead of static methods like Path.GetTempPath or Directory.CreateTempSubdirectory to ensure consistent directory management across the application.

Gets the deployment pipeline for this distributed application.
public abstract IDistributedApplicationPipeline Pipeline { get; }
The pipeline allows adding custom deployment steps that execute during the deploy process. Steps can declare dependencies on other steps to control execution order.
Gets the collection of resources for the distributed application.
public abstract IResourceCollection Resources { get; }
This can be mutated by adding more resources, which will update its current view.
Services Section titled Services abstract IServiceCollection
Gets a collection of services for the application to compose. This is useful for adding user provided or framework provided services.
public abstract IServiceCollection Services { get; }
Gets the service for managing user secrets.
public virtual IUserSecretsManager UserSecretsManager { get; }

The IDistributedApplicationBuilder.UserSecretsManager provides a centralized way to manage user secrets used by Aspire, enabling testability and consistent secret management.