{"record":{"id":"4e4aa5c0d4be3741","repo":"stride3d/stride","slug":"could-not-restore-commandspackageid-version-needed-to","errorCode":null,"errorMessage":"Could not restore {CommandsPackageId} {version} (needed to regenerate shader code). Check your NuGet sources.","messagePattern":"Could not restore (.+?) (.+?) \\(needed to regenerate shader code\\)\\. Check your NuGet sources\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/launcher/Stride.Cli/Legacy/LegacyShaderCodeGenerator.cs","lineNumber":36,"sourceCode":"/// </summary>\ninternal sealed class LegacyShaderCodeGenerator : IDisposable\n{\n    private const string CommandsPackageId = \"Stride.VisualStudio.Commands\";\n\n    private readonly Process process;\n    private readonly NpClient<IStrideCommands> client;\n\n    private LegacyShaderCodeGenerator(Process process, NpClient<IStrideCommands> client)\n    {\n        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","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/launcher/Stride.Cli/Legacy/LegacyShaderCodeGenerator.cs#L18-L54","documentation":"LegacyShaderCodeGenerator.Start needs the released, version-matched Stride.VisualStudio.Commands NuGet package to spawn as an out-of-process shader-code generator. LocateCommandsExecutable tries restoring that package for several target frameworks; if no restore succeeds or no runnable executable can be mapped, it returns null and Start throws this InvalidOperationException telling the user to check NuGet sources.","triggerScenarios":"RestoreHelper.Restore fails for all tried frameworks (net10.0-windows7.0, net8.0-windows7.0, net6.0-windows7.0, net472), or the restored lock file contains no Stride.VisualStudio.Commands assembly, or LoaderToolLocator.GetExecutable cannot map it — any of which makes LocateCommandsExecutable return null.","commonSituations":"NuGet.config missing or pointing at a feed that lacks the exact Stride version (offline machine, corporate proxy, deleted global-packages cache); requesting a prerelease/patched version not published to the feed; a version range pinned to a package no longer available; network firewall blocking api.nuget.org.","solutions":["Check nuget.config / NuGet sources: add the official Stride feed (or the feed hosting your Stride version) and confirm the exact package version exists there via 'dotnet nuget locals' and nuget.org.","Restore connectivity to the NuGet feed (check proxy/firewall/VPN) and clear a corrupt cache: 'dotnet nuget locals all --clear' then retry.","Verify the requested version string matches a published Stride.VisualStudio.Commands release (typos or 4.0-4.3-only support: this path is only valid for Stride 4.0-4.3).","Run the CLI with NuGet verbose logging to see which restore attempt failed and why."],"exampleFix":"// before (nuget.config missing the Stride feed)\n<packageSources>\n  <add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" />\n</packageSources>\n\n// after\n<packageSources>\n  <add key=\"nuget.org\" value=\"https://api.nuget.org/v3/index.json\" />\n  <add key=\"stride\" value=\"https://api.nuget.org/v3/index.json\" />\n</packageSources>","handlingStrategy":"fallback","validationCode":"// Check the package is restorable before calling Start\nvar range = new VersionRange(new NuGetVersion(version.Version, version.SpecialVersion));\nvar (_, result) = RestoreHelper.Restore(NullLogger.Instance,\n    NuGetFramework.ParseFolder(\"net8.0-windows7.0\"), \"win\", \"Stride.VisualStudio.Commands\", range);\nif (!result.Success)\n    Console.Error.WriteLine($\"Stride.VisualStudio.Commands {version} not restorable — check NuGet sources before regenerating shaders.\");","typeGuard":"static bool VersionIsLegacyShaderCodegenRange(PackageVersion v) =>\n    v.Version is { Major: 4, Minor: >= 0 and <= 3 };","tryCatchPattern":"try {\n    using var gen = LegacyShaderCodeGenerator.Start(version);\n    bytes = gen.Generate(shaderFile, shaderContent);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Could not restore Stride.VisualStudio.Commands\")) {\n    Console.Error.WriteLine(\"Fix NuGet sources / network, then retry: \" + ex.Message);\n    return ExitCode.NuGetFailure;\n}","preventionTips":["Keep a nuget.config in the solution that includes the feed hosting your Stride version.","Pre-warm the package cache on CI machines before running shader regeneration.","Pin to published Stride 4.0-4.3 versions; this legacy generator path is unsupported for 4.4+.","Verify feed connectivity (dotnet restore of a probe package) before invoking the CLI."],"tags":["nuget","package-restore","shader-codegen","stride-cli","dependency-resolution"],"backgroundTag":"missing-dependency","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"}