Watch Aspire live streamsDocsTry Aspire

DotnetProgramResourceBuilderExtensions Methods

ClassMethods5 members
Provides publishing configuration for resources backed by .NET programs.
DisableForwardedHeaders(IResourceBuilder<T>)Section titled DisableForwardedHeaders(IResourceBuilder<T>)extensionIResourceBuilder<T>
Configures the .NET program to omit automatic forwarded-header configuration when publishing.
public static class DotnetProgramResourceBuilderExtensions
{
public static IResourceBuilder<T> DisableForwardedHeaders<T>(
this IResourceBuilder<T> builder)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
IResourceBuilder<T>The resource builder for chaining.
WithDotnetProgramBuildEnvironment(IResourceBuilder<T>, Func<EnvironmentCallbackContext, Task>)Section titled WithDotnetProgramBuildEnvironment(IResourceBuilder<T>, Func<EnvironmentCallbackContext, Task>)extensionIResourceBuilder<T>
Adds a callback that configures build-only environment variables for .NET SDK container publishing.
public static class DotnetProgramResourceBuilderExtensions
{
public static IResourceBuilder<T> WithDotnetProgramBuildEnvironment<T>(
this IResourceBuilder<T> builder,
Func<EnvironmentCallbackContext, Task> callback)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
callbackFunc<EnvironmentCallbackContext, Task>The callback that configures the build environment.
IResourceBuilder<T>The resource builder for chaining.
ArgumentNullException Thrown when builder or callback is null.

Values supplied through this callback affect the publishing MSBuild evaluation and may appear in build diagnostics. They are not a secret transport. Callbacks are evaluated in registration order for each publish build.

When publishing a container, Aspire rejects values that control the output artifact's identity, destination, format, or target platform because downstream publishing steps use the corresponding container build options. Configure those values with WithContainerBuildOptions.

WithDotnetProgramPublishing(IResourceBuilder<T>)Section titled WithDotnetProgramPublishing(IResourceBuilder<T>)extensionIResourceBuilder<T>
Configures a .NET program resource to publish a container image through the .NET SDK.
public static class DotnetProgramResourceBuilderExtensions
{
public static IResourceBuilder<T> WithDotnetProgramPublishing<T>(
this IResourceBuilder<T> builder)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
IResourceBuilder<T>The resource builder for chaining.
InvalidOperationException The resource does not implement IComputeResource or does not carry exactly one stable IProjectMetadata annotation.
This method is intended for .NET language integrations that model programs without deriving from ProjectResource. Ordinary projects created with AddProject are configured automatically.
WithEndpointsInEnvironment(IResourceBuilder<T>, Func<EndpointAnnotation, bool>)Section titled WithEndpointsInEnvironment(IResourceBuilder<T>, Func<EndpointAnnotation, bool>)extensionIResourceBuilder<T>
Configures which endpoints contribute environment variables for the .NET program.
public static class DotnetProgramResourceBuilderExtensions
{
public static IResourceBuilder<T> WithEndpointsInEnvironment<T>(
this IResourceBuilder<T> builder,
Func<EndpointAnnotation, bool> filter)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
filterFunc<EndpointAnnotation, bool>The endpoint inclusion filter.
IResourceBuilder<T>The resource builder for chaining.
Configures the .NET program to run the specified number of replicas.
public static class DotnetProgramResourceBuilderExtensions
{
public static IResourceBuilder<T> WithReplicas<T>(
this IResourceBuilder<T> builder,
int replicas)
{
// ...
}
}
builderIResourceBuilder<T>The resource builder.
replicasintThe number of replicas.
IResourceBuilder<T>The resource builder for chaining.