{"record":{"id":"e186afedd0b38a07","repo":"microsoft/aspire","slug":"the-executable-command-cannot-be-null-empty-or-whitespace","errorCode":null,"errorMessage":"The executable command cannot be null, empty, or whitespace.","messagePattern":"The executable command cannot be null, empty, or whitespace\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting/ApplicationModel/ExecutableLaunchRecipe.cs","lineNumber":211,"sourceCode":"/// </param>\n/// <param name=\"environmentVariables\">The resolved environment variables for the executable.</param>\n/// <param name=\"launchConfigurations\">The serialized launch configurations supplied to an IDE.</param>\n/// <param name=\"displayArguments\">The arguments projected into the dashboard command line.</param>\ninternal sealed class ExecutableLaunchPlan(\n    string command,\n    string workingDirectory,\n    ExecutableLaunchMechanism mechanism,\n    IReadOnlyList<string>? arguments,\n    IEnumerable<KeyValuePair<string, string>> environmentVariables,\n    IEnumerable<JsonElement> launchConfigurations,\n    IEnumerable<ExecutableLaunchArgument> displayArguments)\n{\n    /// <summary>\n    /// Gets the executable path or command name.\n    /// </summary>\n    public string Command { get; } = !string.IsNullOrWhiteSpace(command)\n        ? command\n        : throw new ArgumentException(\"The executable command cannot be null, empty, or whitespace.\", nameof(command));\n\n    /// <summary>\n    /// Gets the working directory for the executable.\n    /// </summary>\n    public string WorkingDirectory { get; } = workingDirectory ?? throw new ArgumentNullException(nameof(workingDirectory));\n\n    /// <summary>\n    /// Gets the selected launch mechanism.\n    /// </summary>\n    public ExecutableLaunchMechanism Mechanism { get; } = mechanism;\n\n    /// <summary>\n    /// Gets the arguments for the selected mechanism, or <see langword=\"null\"/> when they are inherited by the IDE.\n    /// </summary>\n    public IReadOnlyList<string>? Arguments { get; } = arguments?.ToArray();\n\n    /// <summary>\n    /// Gets the resolved environment variables for the executable.","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting/ApplicationModel/ExecutableLaunchRecipe.cs#L193-L229","documentation":"ExecutableLaunchPlan.Command validates at construction that the executable command is a non-empty, non-whitespace string, throwing ArgumentException otherwise. This is an eager constructor guard ensuring launch plans always have a runnable command.","triggerScenarios":"Constructing ExecutableLaunchPlan with null, \"\", or whitespace for the command parameter — e.g., when ExecutableAnnotation.Command was unset/empty and the recipe forwarded it, or custom code builds a launch plan directly.","commonSituations":"A resource pipeline removed or never set the executable command annotation; parsing launch metadata (launchSettings profiles) that yielded an empty command; test code constructing the plan with placeholder empty strings.","solutions":["Ensure the resource has an ExecutableAnnotation with a valid non-empty Command before creating the launch plan","Validate/normalize the command string upstream and fail earlier with a clearer message if empty","Fix custom or test code that constructs ExecutableLaunchPlan directly to supply a real command"],"exampleFix":"// before\nvar plan = new ExecutableLaunchPlan(command: string.Empty, workingDirectory: dir, args: [], env: new());\n// after\nvar plan = new ExecutableLaunchPlan(command: \"dotnet\", workingDirectory: dir, args: [projectPath], env: new());","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(command))\n  throw new ArgumentException(\"Executable command must be provided before building a launch plan.\", nameof(command));","typeGuard":"bool IsValidCommand(string? command) => !string.IsNullOrWhiteSpace(command);","tryCatchPattern":"try { var plan = new ExecutableLaunchPlan(command, wd, args, env); } catch (ArgumentException ex) when (ex.Message.Contains(\"executable command\")) { /* supply a valid command or surface config error */ }","preventionTips":["Always set ExecutableAnnotation.Command on executable resources before pipeline execution","Validate launch-settings profiles parse into non-empty commands","Guard custom launch-plan construction with string.IsNullOrWhiteSpace checks"],"tags":["aspire","executables","arguments"],"backgroundTag":"invalid-argument-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}