# DistributedApplicationBuilder

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.3.0`
- Namespace: `Aspire.Hosting`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/DistributedApplicationBuilder.cs)
- Implements: [IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md)

A builder for creating instances of [DistributedApplication](/reference/api/csharp/aspire.hosting/distributedapplication.md).

## Definition

```csharp
namespace Aspire.Hosting;

public class DistributedApplicationBuilder
    : Aspire.Hosting.IDistributedApplicationBuilder
{
    // ...
}
```

## Remarks

The [DistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder.md) is the primary implementation of [IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md) within Aspire. Typically a developer would interact with instances of this class via the [IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md) interface which was created using one of the [DistributedApplication.CreateBuilder](/reference/api/csharp/aspire.hosting/distributedapplication/methods.md#createbuilder) overloads.

For more information on how to configure the [DistributedApplication](/reference/api/csharp/aspire.hosting/distributedapplication.md) using the the builder pattern see [IDistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/idistributedapplicationbuilder.md).

## Constructors

- [DistributedApplicationBuilder(string[])](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/constructors.md#constructor-string) -- Initializes a new instance of the [DistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder.md) class with the specified options.
- [DistributedApplicationBuilder(DistributedApplicationOptions)](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/constructors.md#constructor-distributedapplicationoptions) -- Initializes a new instance of the [DistributedApplicationBuilder](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder.md) class with the specified options.

## Properties

- [AppHostAssembly](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#apphostassembly) : `Assembly?` `get` -- Assembly of the app host project.
- [AppHostDirectory](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#apphostdirectory) : `string` `get` -- Directory of the project where the app host is located. Defaults to the content root if there's no project.
- [AppHostPath](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#apphostpath) : `string` `get`
- [Configuration](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#configuration) : `ConfigurationManager` `get` -- Gets the set of key/value configuration properties.
- [Environment](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#environment) : `IHostEnvironment` `get` -- Gets the information about the hosting environment an application is running in.
- [Eventing](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#eventing) : [IDistributedApplicationEventing](/reference/api/csharp/aspire.hosting/idistributedapplicationeventing.md) `get` -- Eventing infrastructure for AppHost lifecycle.
- [ExecutionContext](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#executioncontext) : [DistributedApplicationExecutionContext](/reference/api/csharp/aspire.hosting/distributedapplicationexecutioncontext.md) `get` -- Execution context for this invocation of the AppHost.
- [FileSystemService](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#filesystemservice) : [IFileSystemService](/reference/api/csharp/aspire.hosting/ifilesystemservice.md) `get` -- Gets the service for managing Aspire file system operations.
- [Pipeline](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#pipeline) : [IDistributedApplicationPipeline](/reference/api/csharp/aspire.hosting/idistributedapplicationpipeline.md) `get` -- Gets the deployment pipeline for this distributed application.
- [Resources](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#resources) : [IResourceCollection](/reference/api/csharp/aspire.hosting/iresourcecollection.md) `get` -- Gets the collection of resources for the distributed application.
- [Services](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#services) : `IServiceCollection` `get` -- Gets a collection of services for the application to compose. This is useful for adding user provided or framework provided services.
- [UserSecretsManager](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/properties.md#usersecretsmanager) : [IUserSecretsManager](/reference/api/csharp/aspire.hosting/iusersecretsmanager.md) `get` -- Gets the service for managing user secrets.

## Methods

- [AddResource(T)](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/methods.md#addresource-t) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- Adds a resource of type `T` to the distributed application.
- [Build](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/methods.md#build) : [DistributedApplication](/reference/api/csharp/aspire.hosting/distributedapplication.md) -- Builds and returns a new [DistributedApplication](/reference/api/csharp/aspire.hosting/distributedapplication.md) instance. This can only be called once.
- [CreateResourceBuilder(T)](/reference/api/csharp/aspire.hosting/distributedapplicationbuilder/methods.md#createresourcebuilder-t) : [IResourceBuilder<T>](/reference/api/csharp/aspire.hosting/iresourcebuilder-1.md) -- Creates a new resource builder based on an existing resource.
