stride3d/stride · error · OptionException

Need one extra argument

Error message

Need one extra argument

What it means

The locate-devenv command takes exactly one extra argument: the Visual Studio version to search for. RealMain requires commandArgs.Count == 2 (command + one argument) and throws OptionException otherwise.

Solutions

  1. Supply exactly one argument: the Visual Studio version, e.g. 'locate-devenv 17'.
  2. Quote the argument if it contains spaces.
  3. Check the script for accidental extra/missing tokens in the invocation.

Example fix

// before
Stride.Core.Tasks locate-devenv
// after
Stride.Core.Tasks locate-devenv 17
Defensive patterns

Strategy: validation

Validate before calling

if (args.Length != 2 || args[0] != "locate-devenv")
{
    Console.WriteLine("Usage: Stride.Core.Tasks locate-devenv <vsVersion>");
    return 1;
}

Try / catch

try { return RealMain(args); }
catch (OptionException ex) { Console.Error.WriteLine("Usage: locate-devenv <vsVersion>"); return 1; }

Prevention

When it happens

Trigger: Running 'Stride.Core.Tasks locate-devenv' with zero additional arguments, or with more than one.

Common situations: Forgetting the VS version argument in a script; word-splitting in shell causing unexpected argument counts.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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

Appendix: source

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

                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;
                    }
                    case "pack-assets":
                    {
                        if (commandArgs.Count != 3)
                            throw new OptionException("Need two extra arguments", "");

                        var csprojFile = commandArgs[1];
                        var intermediatePackagePath = commandArgs[2];
                        // Host-loadable asset assemblies are passed as repeated --pack-asset-assembly= options.
                        var generatedItems = new List<(string SourcePath, string PackagePath)>();

View on GitHub (pinned to 96fad776d2)