microsoft/aspire · error · ArgumentException

At least one process command success exit code must be…

Error message

At least one process command success exit code must be specified.

What it means

The SuccessExitCodes property setter rejects an empty collection. Aspire requires a process command to declare at least one exit code that counts as success, otherwise the host could never determine whether the process succeeded. Throwing in the setter fails fast at model-construction time.

Solutions

  1. Provide at least one success exit code (typically 0): SuccessExitCodes = new[] { 0 }
  2. Include any additional codes that indicate success for your tool, e.g. new[] { 0, 3010 } for MSI-style restart codes
  3. If building dynamically, guard: if (codes.Count == 0) codes.Add(0); before assigning

Example fix

// before
var options = new ProcessCommandOptions { SuccessExitCodes = [] };
// after
var options = new ProcessCommandOptions { SuccessExitCodes = [0] };
Defensive patterns

Strategy: validation

Validate before calling

if (options.SuccessExitCodes is null || options.SuccessExitCodes.Count == 0)
    throw new ArgumentException("Provide at least one success exit code, e.g. [0].");

Try / catch

try { options.SuccessExitCodes = codes; } catch (ArgumentException ex) { /* supply default [0] */ }

Prevention

When it happens

Trigger: Calling the SuccessExitCodes property setter (directly or via an initializer) on ProcessCommandOptions with an empty list, e.g. new ProcessCommandOptions { SuccessExitCodes = [] } or assigning an emptied List<int>.

Common situations: Copy-pasting options object construction without filling success codes; dynamically building the code list from a source that returned no values; clearing the list before assignment.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/247f654b6a60a1ed. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting/ApplicationModel/ProcessCommandOptions.cs:69

    /// </remarks>
    public bool DisplayImmediately { get; set; } = true;

    /// <summary>
    /// Gets or sets the exit codes that are treated as a successful command invocation when <see cref="GetCommandResult"/> is not specified.
    /// </summary>
    /// <remarks>
    /// The default value is <c>[0]</c>.
    /// </remarks>
    public IReadOnlyList<int> SuccessExitCodes
    {
        get => _successExitCodes;
        set
        {
            ArgumentNullException.ThrowIfNull(value);

            if (value.Count == 0)
            {
                throw new ArgumentException("At least one process command success exit code must be specified.", nameof(value));
            }

            _successExitCodes = value.ToArray();
        }
    }

    /// <summary>
    /// Gets or sets a callback to be invoked after the process exits to determine the result of the command invocation.
    /// </summary>
    /// <remarks>
    /// When specified, <see cref="SuccessExitCodes"/>, <see cref="MaxOutputLineCount"/>, and <see cref="DisplayImmediately"/>
    /// are not applied by the default result handling. The callback can use <see cref="ProcessCommandResultContext.GetFormattedOutput"/>
    /// to format retained process output.
    /// </remarks>
    public Func<ProcessCommandResultContext, Task<ExecuteCommandResult>>? GetCommandResult { get; set; }
}

/// <summary>

View on GitHub (pinned to 25830f84bd)