# ExecutionConfigurationBuilder

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

Provides a builder for constructing an [IExecutionConfigurationResult](/reference/api/csharp/aspire.hosting/iexecutionconfigurationresult.md) for a specific resource in the distributed application model. This resolves command line arguments and environment variables and potentially additional metadata through registered gatherers.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public sealed class ExecutionConfigurationBuilder
    : Aspire.Hosting.ApplicationModel.IExecutionConfigurationBuilder
{
    // ...
}
```

## Remarks

Use [ExecutionConfigurationBuilder](/reference/api/csharp/aspire.hosting/executionconfigurationbuilder.md) when you need to programmatically assemble configuration for a resource, typically by aggregating multiple configuration sources using the gatherer pattern. This builder collects configuration from registered [IExecutionConfigurationGatherer](/reference/api/csharp/aspire.hosting/iexecutionconfigurationgatherer.md) instances, which encapsulate logic for gathering resource-specific command line arguments, environment variables, and other metadata.

The gatherer pattern allows for modular and extensible configuration assembly, where each gatherer can contribute part of the final configuration and allows for collecting only the relevant configuration supported in a given context (i.e. only applying certificate configuration gatherers in supported environments).

Typical usage involves creating a builder for a resource, adding one or more configuration gatherers, and then building the configuration asynchronously.

## Methods

- [AddExecutionConfigurationGatherer(IExecutionConfigurationGatherer)](/reference/api/csharp/aspire.hosting/executionconfigurationbuilder/methods.md#addexecutionconfigurationgatherer-iexecutionconfigurationgatherer) : [IExecutionConfigurationBuilder](/reference/api/csharp/aspire.hosting/iexecutionconfigurationbuilder.md) -- Adds a configuration gatherer to the builder.
- [BuildAsync(DistributedApplicationExecutionContext, ILogger?, CancellationToken)](/reference/api/csharp/aspire.hosting/executionconfigurationbuilder/methods.md#buildasync-distributedapplicationexecutioncontext-ilogger-cancellationtoken) : [Task<IExecutionConfigurationResult>](/reference/api/csharp/aspire.hosting/iexecutionconfigurationresult.md) -- Builds the processed resource configuration (resolved arguments and environment variables).
- [Create(IResource)](/reference/api/csharp/aspire.hosting/executionconfigurationbuilder/methods.md#create-iresource) : [IExecutionConfigurationBuilder](/reference/api/csharp/aspire.hosting/iexecutionconfigurationbuilder.md) `static` -- Creates a new instance of [IExecutionConfigurationBuilder](/reference/api/csharp/aspire.hosting/iexecutionconfigurationbuilder.md).

## Examples

```csharp
var resolvedConfiguration = await ExecutionConfigurationBuilder
    .Create(myResource);
    .WithArgumentsConfig()
    .WithEnvironmentVariablesConfig()
    .BuildAsync(executionContext).ConfigureAwait(false);
```
