{"record":{"id":"c9ec4dd5d4f9fe1d","repo":"stride3d/stride","slug":"could-not-find-package-packageinfo-name-packageinfo-version","errorCode":null,"errorMessage":"Could not find package {packageInfo.Name} {packageInfo.Version}. Ensure packages have been resolved.","messagePattern":"Could not find package (.+?) (.+?)\\. Ensure packages have been resolved\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/Templates/StrideDefaultTemplates.cs","lineNumber":36,"sourceCode":"public static class StrideDefaultTemplates\n{\n    /// <summary>\n    /// Loads default templates. Pass <paramref name=\"loadAssemblyReferences\"/>=false in headless\n    /// test runners so the .sdpkg's referenced assemblies (Stride.Particles etc.) don't get loaded\n    /// from .nuget cache — a later sample regen loads them from the sample's bin/ via a different\n    /// path, producing duplicate Assembly objects and a DataContract alias conflict at runtime.\n    /// </summary>\n    public static void Load(bool loadAssemblyReferences = true)\n    {\n        // Only TemplateFolders are needed here (loaded regardless of this flag); skip the package's\n        // assets — they're unused for template registration and slow to load.\n        var loadParams = new PackageLoadParameters { LoadAssemblyReferences = loadAssemblyReferences, AutoLoadTemporaryAssets = false };\n        foreach (var packageInfo in new[] { new { Name = \"Stride.Assets.Presentation\", Version = StrideVersion.NuGetVersion }, new { Name = \"Stride.SpriteStudio.Offline\", Version = StrideVersion.NuGetVersion } })\n        {\n            var logger = new LoggerResult();\n            var packageFile = PackageStore.Instance.GetPackageFileName(packageInfo.Name, new PackageVersionRange(new PackageVersion(packageInfo.Version)));\n            if (packageFile is null)\n                throw new InvalidOperationException($\"Could not find package {packageInfo.Name} {packageInfo.Version}. Ensure packages have been resolved.\");\n            var package = Package.Load(logger, packageFile.ToOSPath(), loadParams);\n            if (logger.HasErrors)\n                throw new InvalidOperationException($\"Could not load package {packageInfo.Name}:{Environment.NewLine}{logger.ToText()}\");\n\n            TemplateManager.RegisterPackage(package);\n        }\n\n        DotNetNewTemplateBridge.RegisterProjectTemplates();\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":47,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/Templates/StrideDefaultTemplates.cs#L18-L47","documentation":"StrideDefaultTemplates.Load resolves the built-in template packages (Stride.Assets.Presentation and Stride.SpriteStudio.Offline) at exactly StrideVersion.NuGetVersion via PackageStore; if GetPackageFileName returns null the package was never downloaded/resolved into the store, so it throws InvalidOperationException.","triggerScenarios":"Creating a new project/template while the NuGet packages cache does not contain the two required packages at the current Stride version — e.g. offline install, blocked network, or version skew between the editor and restored packages.","commonSituations":"Corporate proxy/NuGet feed blocked; installed Stride via source build without running package restore; NuGet global-packages folder cleaned; version mismatch after upgrading the editor.","solutions":["Restore the Stride NuGet packages (open the launcher/Game Studio to trigger download, or `dotnet restore` on a project referencing them) for the exact StrideVersion.","Check network/proxy/NuGet source configuration so packages can be fetched.","Verify the package cache (%USERPROFILE%\\.nuget\\packages\\stride.assets.presentation) contains the expected version; reinstall Stride if not.","Ensure the editor version and StrideVersion.NuGetVersion agree; downgrade/upgrade to matching versions."],"exampleFix":"// before: offline machine, store empty\n// after\ndotnet nuget add source https://api.nuget.org/v3/index.json\ndotnet restore MyGame.csproj // pulls stride.assets.presentation <version>","handlingStrategy":"try-catch","validationCode":"var pkg = PackageStore.Instance.GetPackageFileName(\n    \"Stride.Assets.Presentation\",\n    new PackageVersionRange(new PackageVersion(StrideVersion.NuGetVersion)));\nif (pkg is null)\n    throw new InvalidOperationException($\"Restore stride.assets.presentation {StrideVersion.NuGetVersion} first.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    StrideDefaultTemplates.Load(session, logger);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Could not find package\"))\n{\n    logger.Error($\"Run package restore / check NuGet sources: {ex.Message}\");\n}","preventionTips":["Ensure NuGet.org (or your feed) is reachable and configured before using templates","Keep the Stride editor and package versions aligned","Pre-warm the package cache on build agents used for template generation"],"tags":["templates","nuget","package-resolution"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}