# Retired compiler warning ASPIRECOMMAND001

<Badge
  text="Version introduced: 13.2"
  variant="note"
  size="large"
  class:list={'mb-1'}
/>

:::note[Retired in Aspire 17.0]
Starting with Aspire 17.0, the required-command validation APIs (the `WithRequiredCommand` overload that accepts a validation callback, `RequiredCommandAnnotation`, `IRequiredCommandValidator`, `RequiredCommandValidationContext`, and `RequiredCommandValidationResult`) are stable and no longer report `ASPIRECOMMAND001`. After you upgrade, remove any `ASPIRECOMMAND001` suppressions from _.editorconfig_ files, project files, and `#pragma warning` directives. For current usage, see [Declare required commands](/app-host/executable-resources/#declare-required-commands). The rest of this page describes the diagnostic as it applied to earlier versions.
:::

> Required command validation types and members are for evaluation purposes only and are subject to change or removal in future updates. Suppress this diagnostic to proceed.

This diagnostic warning is reported when using the experimental required-command validation APIs. These APIs let an AppHost run custom validation against a resource's required command or executable before the resource starts.

The following APIs are protected by this diagnostic:

- The <ApiReference name="Aspire.Hosting.RequiredCommandResourceExtensions.WithRequiredCommand" /> overload that accepts a validation callback (`Func<RequiredCommandValidationContext, Task<RequiredCommandValidationResult>>`)
- `RequiredCommandAnnotation`
- `IRequiredCommandValidator`
- `RequiredCommandValidationContext` and `RequiredCommandValidationResult`

The simpler `WithRequiredCommand(command, helpLink)` overload isn't experimental and doesn't raise this diagnostic.

## Example

The following code generates `ASPIRECOMMAND001`:

```csharp title="AppHost.cs"
var builder = DistributedApplication.CreateBuilder(args);

builder.AddContainer("db", "postgres")
    .WithRequiredCommand(
        "psql",
        context => Task.FromResult(context.Success()));

builder.Build().Run();
```

The diagnostic is triggered because the `WithRequiredCommand` validation-callback overload and the `RequiredCommandValidationContext` type are marked with the `[Experimental("ASPIRECOMMAND001")]` attribute.

## To correct this warning

Suppress the warning with one of the following methods:

- Set the severity of the rule in the _.editorconfig_ file.

  ```ini title=".editorconfig"
  [*.{cs,vb}]
  dotnet_diagnostic.ASPIRECOMMAND001.severity = none
  ```

  For more information about editor config files, see [Configuration files for code analysis rules](/diagnostics/overview/#suppress-in-the-editorconfig-file).

- Add the following `PropertyGroup` to your project file:

  ```xml title="C# project file"
  <PropertyGroup>
      <NoWarn>$(NoWarn);ASPIRECOMMAND001</NoWarn>
  </PropertyGroup>
  ```

- Suppress in code with the `#pragma warning disable ASPIRECOMMAND001` directive:

  ```csharp title="Suppressing the warning"
  #pragma warning disable ASPIRECOMMAND001
  builder.AddContainer("db", "postgres")
      .WithRequiredCommand("psql", context => Task.FromResult(context.Success()));
  #pragma warning restore ASPIRECOMMAND001
  ```