{"record":{"id":"1e877cb4198086ef","repo":"stride3d/stride","slug":"could-not-restore-package-packageid","errorCode":null,"errorMessage":"Could not restore package {packageId}","messagePattern":"Could not restore package (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Packages/NugetStore.cs","lineNumber":606,"sourceCode":"                        foreach (var request in requests)\n                        {\n                            // Limit concurrency to avoid timeout\n                            request.Request.MaxDegreeOfConcurrency = 4;\n                            request.Request.DependencyProviders = providersCache.GetOrCreate(\n                                installPath,\n                                spec.RestoreMetadata.FallbackFolders.ToList(),\n                                progressSources,\n                                context,\n                                NativeLogger);\n\n                            var command = new RestoreCommand(request.Request);\n\n                            // Act\n                            var result = await command.ExecuteAsync();\n\n                            if (!result.Success)\n                            {\n                                throw new InvalidOperationException($\"Could not restore package {packageId}\");\n                            }\n                            var toInstall = result.RestoreGraphs.Last().Install;\n                            NugetRestoreInstalling?.Invoke(toInstall.Count);\n                            foreach (var install in toInstall)\n                            {\n                                var package = result.LockFile.Libraries.FirstOrDefault(x => x.Name == install.Library.Name && x.Version == install.Library.Version);\n                                if (package != null)\n                                {\n                                    var packagePath = Path.Combine(installPath, package.Path);\n                                    OnPackageInstalled(this, new PackageOperationEventArgs(new PackageName(install.Library.Name, install.Library.Version.ToPackageVersion()), packagePath));\n                                }\n                            }\n                        }\n                    }\n\n                    if (packageId == \"Xenko\" && version < new PackageVersion(3, 0, 0, 0))\n                    {\n                        UpdateTargetsHelper();","sourceCodeStart":588,"sourceCodeEnd":624,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Packages/NugetStore.cs#L588-L624","documentation":"Thrown by NugetStore.InstallPackage after running a NuGet restore command whose result.Success is false — the runtime restore of a package failed and no install graph could be read. The library surfaces the raw failure as an InvalidOperationException keyed by packageId because NuGet's restore result does not itself throw.","triggerScenarios":"Calling NugetStore.InstallPackage (directly or via installedPackage) when NuGet's RestoreCommand.ExecuteAsync returns a result with Success == false — e.g. the package/version does not exist in the configured sources, the feed is unreachable, or auth fails.","commonSituations":"Offline or misconfigured NuGet feed (wrong source URL, expired credentials); requesting a package version that was unlisted/deleted; corporate proxy blocking nuget.org; corrupted NuGet http-cache.","solutions":["Verify the package id and exact version exist on the configured sources (nuget.org or custom feed) and correct the arguments","Run the restore manually (dotnet restore / nuget restore against the same source) to see the underlying NuGet error message","Check network/proxy and feed credentials; add the feed via nuget.config or NugetStore source configuration and retry","Clear the NuGet cache (dotnet nuget locals http-cache --clear) and retry; wrap InstallPackage in try/catch to report packageId"],"exampleFix":"// before\nvar package = await store.InstallPackage(null, LogProgress, new PackageName(\"MyGame.Plugin\", \"1.0.0\"));\n// after\ntry\n{\n    var package = await store.InstallPackage(null, LogProgress, new PackageName(\"MyGame.Plugin\", \"1.0.0\"));\n}\ncatch (InvalidOperationException ex)\n{\n    Log.Error($\"Restore failed for {ex.Message}; check feed URL, credentials and version.\");\n}","handlingStrategy":"retry","validationCode":"var exists = await store.FindSourcePackage(new NugetVersion(packageName.Version, packageName.Version)); // confirm id/version exists before installing\nif (exists == null) throw new ArgumentException($\"Package {packageName} not found in configured sources\");","typeGuard":"bool IsRestoreFailure(InvalidOperationException ex) => ex.Message.StartsWith(\"Could not restore package\");","tryCatchPattern":"try { return await store.InstallPackage(null, progress, packageName); } catch (InvalidOperationException ex) { log.Error($\"Restore of {packageName} failed: {ex.Message}\"); throw; }","preventionTips":["Verify package id and version exist in the configured NuGet sources before installing","Check feed URL, credentials and proxy settings in nuget.config","Clear the NuGet http cache when restores fail after partial downloads","Add retry with backoff for transient feed/network failures"],"tags":["nuget","package-restore","network","versioning"],"backgroundTag":"http-request-failed","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"}