DebugSupportExtensions Methods
CreateLaunchConfigurationAsync(IResource, string, CancellationToken)Section titled CreateLaunchConfigurationAsync(IResource, string, CancellationToken)extensionTask<object>public static class DebugSupportExtensions{ public static Task<object> CreateLaunchConfigurationAsync( this IResource resource, string mode, CancellationToken cancellationToken = default(CancellationToken)) { // ... }}Parameters
resourceIResourceThe resource to inspect. It must carry a SupportsDebuggingAnnotation.modestringThe launch mode, one of the values on ExecutableLaunchMode.cancellationTokenCancellationTokenoptionalA token to cancel the operation.Returns
Task<object>The launch configuration, typically an ExecutableLaunchConfiguration.Exceptions
InvalidOperationExceptionThe resource does not declare debug launch support.Remarks
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)extensionboolpublic static class DebugSupportExtensions{ public static bool HasLaunchToolArgsOwnedBy( this IResource resource, SupportsDebuggingAnnotation supportsDebuggingAnnotation) { // ... }}Parameters
resourceIResourceThe resource to inspect.supportsDebuggingAnnotationSupportsDebuggingAnnotationThe launch configuration annotation to compare.Returns
booltrue when the launch configuration supplies the tool invocation; otherwise, false.Remarks
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?)extensionboolpublic static class DebugSupportExtensions{ public static bool SupportsDebugging( this IResource resource, IConfiguration configuration, out SupportsDebuggingAnnotation? supportsDebuggingAnnotation) { // ... }}Parameters
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.Returns
booltrue when the IDE owns launching this resource; otherwise false.Remarks
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.