{"record":{"id":"1ece400fe5f4fb0f","repo":"stride3d/stride","slug":"failed-to-start-commandspackageid-version","errorCode":null,"errorMessage":"Failed to start {CommandsPackageId} {version}.","messagePattern":"Failed to start (.+?) (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/launcher/Stride.Cli/Legacy/LegacyShaderCodeGenerator.cs","lineNumber":46,"sourceCode":"        this.process = process;\n        this.client = client;\n    }\n\n    /// <summary>Restores the version-matched Commands, spawns it, and connects. Caller owns the returned instance.</summary>\n    public static LegacyShaderCodeGenerator Start(PackageVersion version)\n    {\n        var executable = LocateCommandsExecutable(version)\n            ?? throw new InvalidOperationException($\"Could not restore {CommandsPackageId} {version} (needed to regenerate shader code). Check your NuGet sources.\");\n\n        var address = \"Stride/StrideCliShaders/\" + Guid.NewGuid();\n        var startInfo = new ProcessStartInfo(executable, $\"--pipe=\\\"{address}\\\"\")\n        {\n            UseShellExecute = false,\n            CreateNoWindow = true,\n            WorkingDirectory = Path.GetDirectoryName(executable)!,\n        };\n        var process = Process.Start(startInfo)\n            ?? throw new InvalidOperationException($\"Failed to start {CommandsPackageId} {version}.\");\n\n        // Stride 4.1 spoke ServiceWire 5.3.4 (BinaryFormatter, no compression); 4.2+ uses the modern default.\n        var legacy = version.Version < new Version(4, 2);\n\n        // The server needs a moment to open its named pipe; retry the connection briefly.\n        for (var attempt = 0; ; attempt++)\n        {\n            try\n            {\n                var endpoint = new NpEndPoint(address + \"/IStrideCommands\");\n                var client = legacy\n                    ? new NpClient<IStrideCommands>(endpoint, new LegacyBinaryFormatterSerializer(), new LegacyDoNothingCompressor())\n                    : new NpClient<IStrideCommands>(endpoint);\n                return new LegacyShaderCodeGenerator(process, client);\n            }\n            catch when (attempt < 30 && !process.HasExited)\n            {\n                Thread.Sleep(100);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/launcher/Stride.Cli/Legacy/LegacyShaderCodeGenerator.cs#L28-L64","documentation":"After locating and launching the version-matched Stride.VisualStudio.Commands executable, Start calls Process.Start; if the OS returns null (the process could not be launched), this InvalidOperationException is thrown. Unlike the connection loop, this failure happens before any pipe retry logic and indicates the executable itself could not be spawned.","triggerScenarios":"Process.Start(new ProcessStartInfo(executable, \"--pipe=...\") { UseShellExecute = false }) returns null — typically because the mapped executable path is not a launchable process image on the current OS/architecture.","commonSituations":"LoaderToolLocator mapped the restored assembly to a host not runnable on this machine (wrong architecture, e.g. x86 vs arm64, or a Windows-only host); antivirus or policy blocking execution of the downloaded tool; a net6.0/net8.0/net10.0 apphost whose matching runtime is absent so the launcher refuses to start it; file marked not-executable or blocked (Zone.Identifier) after download.","solutions":["Confirm the mapped executable runs standalone: execute the path printed in the error manually and fix whatever blocks it (missing .NET runtime, unblock the file, adjust antivirus).","Install the .NET runtime matching the framework folder the Commands package restored under (net10.0/net8.0/net6.0) for your OS and architecture.","Re-restore the package after clearing caches ('dotnet nuget locals all --clear') in case the apphost binary is corrupt.","Check OS security policies (AppLocker/Defender/quarantine) that silently prevent spawning the tool executable."],"exampleFix":"// before (blocked/unlaunchable apphost)\nC:\\Users\\me\\.nuget\\packages\\stride.visualstudio.commands\\4.1.0\\...\\Stride.VisualStudio.Commands.exe  <- returns null from Process.Start\n\n// after (unblock and verify runtime)\nUnblock-File .\\Stride.VisualStudio.Commands.exe\ndotnet --list-runtimes   # ensure the required runtime is installed","handlingStrategy":"try-catch","validationCode":"// Verify the mapped executable is launchable before spawning\nvar exe = LocateCommandsExecutable(version);\nif (exe is null || !File.Exists(exe))\n    throw new InvalidOperationException(\"Commands executable missing — check the NuGet restore first.\");\nif (!OperatingSystem.IsWindows())\n    Console.Error.WriteLine(\"Commands host is Windows-targeted; Process.Start may fail on this OS.\");","typeGuard":"static bool CanLaunch(string path) =>\n    File.Exists(path) &&\n    (OperatingSystem.IsWindows() || !(path.EndsWith(\".exe\", StringComparison.OrdinalIgnoreCase)));","tryCatchPattern":"try {\n    using var gen = LegacyShaderCodeGenerator.Start(version);\n    bytes = gen.Generate(shaderFile, shaderContent);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Failed to start Stride.VisualStudio.Commands\")) {\n    Console.Error.WriteLine($\"Tool spawn failed: {ex.Message}. Check installed .NET runtimes and AV policy.\");\n    return ExitCode.LaunchFailure;\n}","preventionTips":["Ensure the .NET runtimes (net6.0/net8.0/net10.0 as applicable) are installed for the architecture the Commands apphost was restored for.","Unblock downloaded package binaries and confirm antivirus/AppLocker does not block the tool's exe.","Smoke-test the tool executable manually once per machine before relying on the CLI.","Run 'dotnet --list-runtimes' in CI images to keep the required runtimes present."],"tags":["process-launch","nuget","shader-codegen","stride-cli","windows"],"backgroundTag":"command-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}