Share via


ResourceBuilderExtensions.WithExplicitStart<T> Method

Definition

Adds a ExplicitStartupAnnotation annotation to the resource so it doesn't automatically start with the app host startup.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithExplicitStart<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder) where T : Aspire.Hosting.ApplicationModel.IResource;
static member WithExplicitStart : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)
<Extension()>
Public Function WithExplicitStart(Of T As IResource) (builder As IResourceBuilder(Of T)) As IResourceBuilder(Of T)

Type Parameters

T

The type of the resource.

Parameters

builder
IResourceBuilder<T>

The resource builder.

Returns

The IResourceBuilder<T>.

Examples

The database clean up tool project isn't started with the app host. The resource start command can be used to run it ondemand later.

var builder = DistributedApplication.CreateBuilder(args);
var pgsql = builder.AddPostgres("postgres");
builder.AddProject<Projects.CleanUpDatabase>("dbcleanuptool")
       .WithReference(pgsql)
       .WithExplicitStart();

Remarks

This method is useful when a resource shouldn't automatically start when the app host starts.

Applies to