Skip to content
DocsTry Aspire
DocsTry

DebugSupportExtensions Methods

ClassMethods3 members
Extension methods for inspecting whether a resource will be launched by an IDE or extension host for debugging rather than started as a plain process by Aspire.
CreateLaunchConfigurationAsync(IResource, string, CancellationToken)Section titled CreateLaunchConfigurationAsync(IResource, string, CancellationToken)extensionTask<object>
Creates the launch configuration that this resource sends to the IDE for the given launch mode.
public static class DebugSupportExtensions
{
public static Task<object> CreateLaunchConfigurationAsync(
this IResource resource,
string mode,
CancellationToken cancellationToken = default(CancellationToken))
{
// ...
}
}
resourceIResourceThe resource to inspect. It must carry a SupportsDebuggingAnnotation.
modestringThe launch mode, one of the values on ExecutableLaunchMode.
cancellationTokenCancellationTokenoptionalA token to cancel the operation.
Task<object>The launch configuration, typically an ExecutableLaunchConfiguration.
InvalidOperationExceptionThe resource does not declare debug launch support.

Launch configuration is created by invoking the producer callback passed to ResourceBuilderExtensions.WithDebugSupport (or its asynchronous overload), which owns the complete configuration; Aspire serializes the result as-is. The configuration is produced fresh on each call; it is not a singleton. Aspire may call the producer several times for the same resource.

This describes the launch configuration itself, not whether one is going to be used. Depending on how the application is started, or how a resource is configured, Aspire may or may not run the resource under a debugger. Use DebugSupportExtensions.SupportsDebugging to test for that.

HasLaunchToolArgsOwnedBy(IResource, SupportsDebuggingAnnotation)Section titled HasLaunchToolArgsOwnedBy(IResource, SupportsDebuggingAnnotation)extensionbool
Determines whether the launch configuration performs the resource's tool invocation itself, meaning the resource's launch tool arguments must not also be passed to the launched program.
public static class DebugSupportExtensions
{
public static bool HasLaunchToolArgsOwnedBy(
this IResource resource,
SupportsDebuggingAnnotation supportsDebuggingAnnotation)
{
// ...
}
}
resourceIResourceThe resource to inspect.
supportsDebuggingAnnotationSupportsDebuggingAnnotationThe launch configuration annotation to compare.
booltrue when the launch configuration supplies the tool invocation; otherwise, false.
This is false for a resource whose launch tool arguments declare no owning launch configuration type, because such a prefix is always passed to the program.
SupportsDebugging(IResource, IConfiguration, SupportsDebuggingAnnotation?)Section titled SupportsDebugging(IResource, IConfiguration, SupportsDebuggingAnnotation?)extensionbool
Determines whether the resource will be launched by the IDE for debugging in the current session.
public static class DebugSupportExtensions
{
public static bool SupportsDebugging(
this IResource resource,
IConfiguration configuration,
out SupportsDebuggingAnnotation? supportsDebuggingAnnotation)
{
// ...
}
}
resourceIResourceThe resource to inspect.
configurationIConfigurationThe AppHost configuration, used to detect the active debug session and its capabilities.
supportsDebuggingAnnotationSupportsDebuggingAnnotation?When this method returns true, the annotation describing how the resource is launched.
booltrue when the IDE owns launching this resource; otherwise false.

Integrations use this to decide whether to build a runnable command line for the resource. When the IDE launches the resource, arguments such as dotnet run --project … or go run … are supplied by the IDE instead and must not be produced by the integration.

A resource is only considered debuggable when it carries a SupportsDebuggingAnnotation, a debug session is active, the resource is not forced to process execution, it does not have a persistent lifetime, and the IDE advertised support for the annotation's launch configuration type.

Exception: when the active debug session did not advertise any launch configuration types at all (for example Visual Studio, which does not send a capability list), a resource whose launch configuration type is KnownLaunchConfigurationTypes.Project is treated as implicitly supported rather than falling back to plain process execution.