stride3d/stride · error · OptionException

This option is only available on Windows

Error message

This option is only available on Windows

What it means

The locate-devenv command uses Windows-only Visual Studio discovery APIs (LocateDevenv.FindDevenv). RealMain explicitly checks OperatingSystem.IsWindows() and throws this OptionException when the command is used on any other OS.

Solutions

  1. Run this command on Windows only.
  2. On non-Windows, use the platform's build tool directly (e.g. dotnet msbuild) instead of locating devenv.
  3. Wrap the call in an OS check in your script and skip or substitute an alternative.

Example fix

// before
Stride.Core.Tasks locate-devenv 17
// after (script guard)
if [[ "$OSTYPE" == msys* || "$OSTYPE" == cygwin* ]]; then Stride.Core.Tasks locate-devenv 17; else dotnet msbuild MyGame.sln; fi
Defensive patterns

Strategy: fallback

Validate before calling

if (!OperatingSystem.IsWindows())
{
    Console.WriteLine("locate-devenv requires Windows; using dotnet msbuild fallback");
    return RunFallbackBuild();
}

Try / catch

try { LocateDevenvFlow(); }
catch (OptionException ex) when (ex.Message.Contains("Windows")) { UseCrossPlatformBuild(); }

Prevention

When it happens

Trigger: Running 'Stride.Core.Tasks locate-devenv <version>' on Linux or macOS.

Common situations: Porting a Windows build script to a Linux CI agent; running the tool in a cross-platform Docker image; trying to locate Visual Studio from WSL without Windows context.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


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

Appendix: source

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

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

                        var csprojFile = commandArgs[1];

View on GitHub (pinned to 96fad776d2)