# DebugSupportExtensions Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [DebugSupportExtensions](/reference/api/csharp/aspire.hosting/debugsupportextensions.md)
- Kind: `Methods`
- Members: `3`

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.

<a id="createlaunchconfigurationasync"></a>
<a id="createlaunchconfigurationasync-iresource-string-cancellationtoken"></a>

## CreateLaunchConfigurationAsync(IResource, string, CancellationToken)

- Name: `CreateLaunchConfigurationAsync(IResource, string, CancellationToken)`
- Modifiers: `extension`
- Returns: `Task<object>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/b5f143315ffb6968ea939a9978797a5b20e4c688/src/Aspire.Hosting/ApplicationModel/DebugSupportExtensions.cs#L124-L135)

Creates the launch configuration that this resource sends to the IDE for the given launch mode.

```csharp
public static class DebugSupportExtensions
{
    public static Task<object> CreateLaunchConfigurationAsync(
        this IResource resource,
        string mode,
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `resource` ([IResource](/reference/api/csharp/aspire.hosting/iresource.md))
  The resource to inspect. It must carry a [SupportsDebuggingAnnotation](/reference/api/csharp/aspire.hosting/supportsdebuggingannotation.md).
- `mode` (`string`)
  The launch mode, one of the values on [ExecutableLaunchMode](/reference/api/csharp/aspire.hosting/executablelaunchmode.md).
- `cancellationToken` (`CancellationToken`) `optional`
  A token to cancel the operation.

## Returns

`Task<object>` -- The launch configuration, typically an [ExecutableLaunchConfiguration](/reference/api/csharp/aspire.hosting/executablelaunchconfiguration.md).

## Exceptions

- `InvalidOperationException` -- The resource does not declare debug launch support.

## Remarks

Launch configuration is created by invoking the producer callback passed to [ResourceBuilderExtensions.WithDebugSupport(IResourceBuilder<T>, Func<string, TLaunchConfiguration>, string)](/reference/api/csharp/aspire.hosting/resourcebuilderextensions/methods.md#withdebugsupport-iresourcebuilder-t-func-string-tlaunchconfiguration-string) (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(IResource, IConfiguration, SupportsDebuggingAnnotation?)](/reference/api/csharp/aspire.hosting/debugsupportextensions/methods.md#supportsdebugging-iresource-iconfiguration-supportsdebuggingannotation) to test for that.

## ATS metadata

### Ignored by ATS

- Reason: Debug support inspection is a local .NET helper and is not part of the ATS surface.

<a id="haslaunchtoolargsownedby"></a>
<a id="haslaunchtoolargsownedby-iresource-supportsdebuggingannotation"></a>

## HasLaunchToolArgsOwnedBy(IResource, SupportsDebuggingAnnotation)

- Name: `HasLaunchToolArgsOwnedBy(IResource, SupportsDebuggingAnnotation)`
- Modifiers: `extension`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/b5f143315ffb6968ea939a9978797a5b20e4c688/src/Aspire.Hosting/ApplicationModel/DebugSupportExtensions.cs#L90-L95)

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.

```csharp
public static class DebugSupportExtensions
{
    public static bool HasLaunchToolArgsOwnedBy(
        this IResource resource,
        SupportsDebuggingAnnotation supportsDebuggingAnnotation)
    {
        // ...
    }
}
```

## Parameters

- `resource` ([IResource](/reference/api/csharp/aspire.hosting/iresource.md))
  The resource to inspect.
- `supportsDebuggingAnnotation` ([SupportsDebuggingAnnotation](/reference/api/csharp/aspire.hosting/supportsdebuggingannotation.md))
  The launch configuration annotation to compare.

## Returns

`bool` -- `true` when the launch configuration supplies the tool invocation; otherwise, `false`.

## Remarks

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.

## ATS metadata

### Ignored by ATS

- Reason: Debug support inspection is a local .NET helper and is not part of the ATS surface.

<a id="supportsdebugging"></a>
<a id="supportsdebugging-iresource-iconfiguration-supportsdebuggingannotation"></a>

## SupportsDebugging(IResource, IConfiguration, SupportsDebuggingAnnotation?)

- Name: `SupportsDebugging(IResource, IConfiguration, SupportsDebuggingAnnotation?)`
- Modifiers: `extension`
- Returns: `bool`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/b5f143315ffb6968ea939a9978797a5b20e4c688/src/Aspire.Hosting/ApplicationModel/DebugSupportExtensions.cs#L47-L73)

Determines whether the resource will be launched by the IDE for debugging in the current session.

```csharp
public static class DebugSupportExtensions
{
    public static bool SupportsDebugging(
        this IResource resource,
        IConfiguration configuration,
        out SupportsDebuggingAnnotation? supportsDebuggingAnnotation)
    {
        // ...
    }
}
```

## Parameters

- `resource` ([IResource](/reference/api/csharp/aspire.hosting/iresource.md))
  The resource to inspect.
- `configuration` (`IConfiguration`)
  The AppHost configuration, used to detect the active debug session and its capabilities.
- `supportsDebuggingAnnotation` ([SupportsDebuggingAnnotation?](/reference/api/csharp/aspire.hosting/supportsdebuggingannotation.md))
  When this method returns `true`, the annotation describing how the resource is launched.

## Returns

`bool` -- `true` 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](/reference/api/csharp/aspire.hosting/supportsdebuggingannotation.md), 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](/reference/api/csharp/aspire.hosting/knownlaunchconfigurationtypes/fields.md#project) is treated as implicitly supported rather than falling back to plain process execution.

## ATS metadata

### Ignored by ATS

- Reason: Debug support inspection is a local .NET helper and is not part of the ATS surface.
