stride3d/stride · error · OptionException

You need to specify a command

Error message

You need to specify a command

What it means

The Stride.Core.Tasks command-line tool requires a command as its first positional argument (e.g. locate-devenv, pack-assets). When commandArgs is empty, RealMain throws OptionException telling you a command must be supplied.

Solutions

  1. Pass a valid command as the first argument, e.g. Stride.Core.Tasks pack-assets <csproj> <intermediatePath>.
  2. Run the tool with --help to list available commands and their expected arguments.
  3. Fix the build script quoting so arguments are forwarded correctly.

Example fix

// before
Stride.Core.Tasks
// after
Stride.Core.Tasks locate-devenv "C:\Program Files\Microsoft Visual Studio"
Defensive patterns

Strategy: validation

Validate before calling

// before invoking, check args
if (args.Length == 0)
{
    Console.WriteLine("Usage: Stride.Core.Tasks <command> [args]");
    return 1;
}

Try / catch

try { return RealMain(args); }
catch (OptionException ex) { Console.Error.WriteLine(ex.Message); return 1; }

Prevention

When it happens

Trigger: Running the tool executable with no positional arguments, or only with options such that commandArgs.Count == 0.

Common situations: Invoking the tool bare to 'see what happens'; a build script that drops its arguments due to quoting issues; calling it expecting a GUI or default command.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/86ffb13e8a1f5472. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Tasks/Program.cs:77

                string.Empty,
                "=== Options ===",
                string.Empty,
                { "pack-asset-assembly=", "Host-loadable asset assembly (package-relative path) to declare in the packed sdpkg; repeat for each", v => packAssetAssemblies.Add(v) },
                { "h|help", "Show this message and exit", v => showHelp = v != null },
            };

            try
            {
                var commandArgs = p.Parse(args);
                if (showHelp)
                {
                    p.WriteOptionDescriptions(Console.Out);
                    return 0;
                }

                // Make sure path exists
                if (commandArgs.Count == 0)
                    throw new OptionException("You need to specify a command", "");

                switch (commandArgs[0])
                {
                    case "locate-devenv":
                    {
                        if(!OperatingSystem.IsWindows())
                            throw new OptionException("This option is only available on Windows", "");
                            
                        if (commandArgs.Count != 2)
                            throw new OptionException("Need one extra argument", "");
                        var devenvPath = LocateDevenv.FindDevenv(commandArgs[1]);
                        if (devenvPath == null)
                        {
                            Console.WriteLine("Could not locate devenv");
                            return 1;
                        }
                        Console.WriteLine(devenvPath);
                        break;

View on GitHub (pinned to 96fad776d2)