Перейти до вмісту
Docs Try Aspire
Docs Try

Compiler Warning ASPIREPROCESSCOMMAND001

Цей контент ще не доступний вашою мовою.

Version introduced: 13.4

Process command 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 WithProcessCommand extension method and related process command APIs. These APIs enable AppHost authors to expose custom resource commands backed by local processes (binaries, shell scripts, and other executables on the AppHost machine).

The following APIs are protected by this diagnostic:

  • WithProcessCommand on IResourceBuilder<T> — registers a command that starts a local process when invoked
  • ProcessCommandSpec — describes the process to start, including executable path, arguments, environment variables, working directory, and stdin content
  • ProcessCommandOptions — controls command behavior such as the maximum captured output line count, success exit codes, and how the result is displayed

The following code generates ASPIREPROCESSCOMMAND001:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
builder.AddRedis("cache")
.WithProcessCommand(
name: "dotnet-version",
displayName: "Show .NET version",
executablePath: "dotnet",
arguments: ["--version"]);
builder.Build().Run();

The diagnostic is triggered because WithProcessCommand, ProcessCommandSpec, and ProcessCommandOptions are all marked with the [Experimental("ASPIREPROCESSCOMMAND001")] attribute.

Suppress the warning with one of the following methods:

  • Set the severity of the rule in the .editorconfig file.

    .editorconfig
    [*.{cs,vb}]
    dotnet_diagnostic.ASPIREPROCESSCOMMAND001.severity = none

    For more information about editor config files, see Configuration files for code analysis rules.

  • Add the following PropertyGroup to your project file:

    C# project file
    <PropertyGroup>
    <NoWarn>$(NoWarn);ASPIREPROCESSCOMMAND001</NoWarn>
    </PropertyGroup>
  • Suppress in code with the #pragma warning disable ASPIREPROCESSCOMMAND001 directive:

    C# — Suppressing the warning
    #pragma warning disable ASPIREPROCESSCOMMAND001
    builder.AddRedis("cache")
    .WithProcessCommand("dotnet-version", "Show .NET version", "dotnet", ["--version"]);
    #pragma warning restore ASPIREPROCESSCOMMAND001