stride3d/stride · error · InvalidOperationException
Could not find package
Error message
Could not find package {packageInfo.Name} {packageInfo.Version}. Ensure packages have been resolved. What it means
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.
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.
Example fix
// before: offline machine, store empty // after dotnet nuget add source https://api.nuget.org/v3/index.json dotnet restore MyGame.csproj // pulls stride.assets.presentation <version>
Defensive patterns
Strategy: try-catch
Validate before calling
var pkg = PackageStore.Instance.GetPackageFileName(
"Stride.Assets.Presentation",
new PackageVersionRange(new PackageVersion(StrideVersion.NuGetVersion)));
if (pkg is null)
throw new InvalidOperationException($"Restore stride.assets.presentation {StrideVersion.NuGetVersion} first."); Try / catch
try
{
StrideDefaultTemplates.Load(session, logger);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Could not find package"))
{
logger.Error($"Run package restore / check NuGet sources: {ex.Message}");
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Could not load package
- Could not restore NuGet packages for
- Asset returned by CreateAssets has no location. Use…
- Could not find installation path for package
- Could not locate native library
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/c9ec4dd5d4f9fe1d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Assets/Templates/StrideDefaultTemplates.cs:36
public static class StrideDefaultTemplates
{
/// <summary>
/// Loads default templates. Pass <paramref name="loadAssemblyReferences"/>=false in headless
/// test runners so the .sdpkg's referenced assemblies (Stride.Particles etc.) don't get loaded
/// from .nuget cache — a later sample regen loads them from the sample's bin/ via a different
/// path, producing duplicate Assembly objects and a DataContract alias conflict at runtime.
/// </summary>
public static void Load(bool loadAssemblyReferences = true)
{
// Only TemplateFolders are needed here (loaded regardless of this flag); skip the package's
// assets — they're unused for template registration and slow to load.
var loadParams = new PackageLoadParameters { LoadAssemblyReferences = loadAssemblyReferences, AutoLoadTemporaryAssets = false };
foreach (var packageInfo in new[] { new { Name = "Stride.Assets.Presentation", Version = StrideVersion.NuGetVersion }, new { Name = "Stride.SpriteStudio.Offline", Version = StrideVersion.NuGetVersion } })
{
var logger = new LoggerResult();
var packageFile = PackageStore.Instance.GetPackageFileName(packageInfo.Name, new PackageVersionRange(new PackageVersion(packageInfo.Version)));
if (packageFile is null)
throw new InvalidOperationException($"Could not find package {packageInfo.Name} {packageInfo.Version}. Ensure packages have been resolved.");
var package = Package.Load(logger, packageFile.ToOSPath(), loadParams);
if (logger.HasErrors)
throw new InvalidOperationException($"Could not load package {packageInfo.Name}:{Environment.NewLine}{logger.ToText()}");
TemplateManager.RegisterPackage(package);
}
DotNetNewTemplateBridge.RegisterProjectTemplates();
}
}
View on GitHub (pinned to 96fad776d2)