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
resourceISupportsDebuggingAnnotation .modestringThe launch mode, one of the values on ExecutableLaunchMode .cancellationToken CancellationToken optionalA token to cancel the operation.Returns
Task<object> The launch configuration, typically an ExecutableLaunchConfiguration .Exceptions
ArgumentNullExceptionresource or mode is null.InvalidOperationExceptionThe resource does not declare debug launch support.Remarks
Launch configuration is created by invoking the producer callback passed to a With overload on Resource, which owns the complete configuration; Aspire serializes the result as-is. The configuration is produced fresh on each call. Aspire may call the producer several times for the same resource.
This overload does not resolve the resource's environment variables. A context-based producer receives an empty environment. Aspire's executable creation path supplies the resolved environment through the context-aware overload.
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 Debug 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
resourceIsupportsDebuggingAnnotation SupportsReturns
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
resourceIconfigurationIConfiguration The AppHost configuration, used to detect the active debug session and its capabilities.supportsDebuggingAnnotation Supportstrue, 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 - 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 Supports, 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 provide a usable launch configuration capability list (for example Visual Studio, which does not send one), a non-file-based resource whose launch configuration type is Known is treated as implicitly supported. File-based C# apps require explicit IDE support because Visual Studio can only launch projects loaded in the solution.