{"record":{"id":"28914f9808725b30","repo":"stride3d/stride","slug":"could-not-load-package-packageinfo-name-environment-newline","errorCode":null,"errorMessage":"Could not load package {packageInfo.Name}:{Environment.NewLine}{logger.ToText()}","messagePattern":"Could not load package (.+?):(.+?)(.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/Templates/StrideDefaultTemplates.cs","lineNumber":39,"sourceCode":"    /// 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":21,"sourceCodeEnd":47,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/Templates/StrideDefaultTemplates.cs#L21-L47","documentation":"The same Load method as above does find the package file but Package.Load logs errors into a LoggerResult; if logger.HasErrors the package exists yet failed to load, and the full logger text is embedded in the InvalidOperationException. This surfaces deserialization, dependency, or assembly-reference problems with the template package.","triggerScenarios":"Package.Load on Stride.Assets.Presentation or Stride.SpriteStudio.Offline logs errors — corrupt package cache entry, incompatible package version, missing dependency assemblies, or broken package metadata.","commonSituations":"Interrupted download leaving a partial/corrupt package in the NuGet cache; package version restored from a different feed with mismatched dependencies; disk/permission problems while reading the cache.","solutions":["Read the embedded logger output to see the specific load error (missing dependency, deserialize failure, etc.).","Delete the cached package from the NuGet global-packages folder and let it re-download.","Restore a consistent set of Stride package versions (clear all stride.* of mismatched versions and restore).","Reinstall/repair Stride if the corruption persists."],"exampleFix":"// clear corrupt cache entry and restore\nrm -rf ~/.nuget/packages/stride.assets.presentation\ndotnet restore MyGame.csproj","handlingStrategy":"try-catch","validationCode":"var cachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),\n    \".nuget\", \"packages\", \"stride.assets.presentation\", StrideVersion.NuGetVersion);\nif (!Directory.Exists(cachePath) || !Directory.EnumerateFileSystemEntries(cachePath).Any())\n    throw new InvalidOperationException(\"Cached package missing or empty — restore it.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    StrideDefaultTemplates.Load(session, logger);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Could not load package\"))\n{\n    logger.Error($\"Package load failed; clear the NuGet cache entry and restore: {ex.Message}\");\n}","preventionTips":["Let downloads complete; avoid killing restores mid-flight to prevent cache corruption","Use one consistent package source for all stride.* packages","Re-restore after Stride upgrades so versions stay consistent"],"tags":["templates","nuget","package-load"],"backgroundTag":"missing-dependency","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"}