# 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/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting/ApplicationModel/DebugSupportExtensions.cs#L134-L142)

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

- `ArgumentNullException` -- `resource` or `mode` is `null`.
- `InvalidOperationException` -- The resource does not declare debug launch support.

## Remarks

Launch configuration is created by invoking the producer callback passed to a `WithDebugSupport` overload on [ResourceBuilderExtensions](/reference/api/csharp/aspire.hosting/resourcebuilderextensions.md), 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 [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/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting/ApplicationModel/DebugSupportExtensions.cs#L93-L98)

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/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting/ApplicationModel/DebugSupportExtensions.cs#L47-L76)

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. A producer that requires explicit Debug mode uses plain process execution for non-debug launches.

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 [KnownLaunchConfigurationTypes.Project](/reference/api/csharp/aspire.hosting/knownlaunchconfigurationtypes/fields.md#project) is treated as implicitly supported. File-based C# apps require explicit IDE support because Visual Studio can only launch projects loaded in the solution.

## ATS metadata

### Ignored by ATS

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