microsoft/aspire · error · ArgumentException
Launch arguments must contain at least one entry.
Error message
Launch arguments must contain at least one entry.
What it means
ProjectLaunchArgsOverrideAnnotation.ValidateArguments rejects an empty arguments list. An override annotation that replaced launch arguments with an empty set is almost certainly a mistake — the project would be started with no arguments at all — so the annotation fails fast.
Solutions
- Supply at least one launch argument, e.g. new ProjectLaunchArgsOverrideAnnotation(["run"]...)
- Guard before constructing: if (args.Count == 0) args = ["run"];
- If no override is needed, don't add the annotation instead of passing an empty list
Example fix
// before
var annotation = new ProjectLaunchArgsOverrideAnnotation(filteredArgs); // filteredArgs == []
// after
var annotation = filteredArgs.Count > 0
? new ProjectLaunchArgsOverrideAnnotation(filteredArgs)
: new ProjectLaunchArgsOverrideAnnotation(["run"]); Defensive patterns
Strategy: validation
Validate before calling
if (args.Count == 0) args = ["run"]; // or skip adding the annotation var annotation = new ProjectLaunchArgsOverrideAnnotation(args);
Try / catch
try { new ProjectLaunchArgsOverrideAnnotation(args); } catch (ArgumentException) { /* fall back to no override */ } Prevention
- Check Count after filtering args before constructing the annotation
- Skip adding the override annotation when no replacement args exist
When it happens
Trigger: new ProjectLaunchArgsOverrideAnnotation(Array.Empty<string>()) or passing a filtered/derived list that ended up empty to the annotation constructor.
Common situations: Building the argument list by filtering user-supplied args where none matched; passing an uninitialized array; removing the leading resource argument and then assigning the now-empty remainder.
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
- The leading resource argument to remove cannot be empty.
- At least one process command success exit code must be…
- Object must implement IManifestExpressionProvider
- Object must implement IValueProvider
- Resource ' ' cannot produce a " " launch configuration…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/5eb3f3d8695961ec.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting/ApplicationModel/ProjectLaunchArgsOverrideAnnotation.cs:66
internal void Apply(IList<string> projectArgs, string projectPath, string? configuration)
{
projectArgs.AddRange(Arguments);
projectArgs.Add(projectPath);
if (!string.IsNullOrEmpty(configuration))
{
projectArgs.AddRange(["--configuration", configuration]);
}
}
private static IReadOnlyList<string> ValidateArguments(IReadOnlyList<string> arguments)
{
ArgumentNullException.ThrowIfNull(arguments);
if (arguments.Count == 0)
{
throw new ArgumentException("Launch arguments must contain at least one entry.", nameof(arguments));
}
return arguments;
}
private static string? ValidateLeadingResourceArgumentToRemove(string? leadingResourceArgumentToRemove)
{
if (leadingResourceArgumentToRemove is not null && leadingResourceArgumentToRemove.Length == 0)
{
throw new ArgumentException("The leading resource argument to remove cannot be empty.", nameof(leadingResourceArgumentToRemove));
}
return leadingResourceArgumentToRemove;
}
}
View on GitHub (pinned to 25830f84bd)