stride3d/stride · error · IOException

File doesn't appear to be a valid package

Error message

File {filePath} doesn't appear to be a valid package

What it means

Package.GetPackageIdFromFile reads the package file's sline header to extract the package Id GUID. If the Id line cannot be found or parsed before the file ends, it concludes the file is not a valid Stride package and throws IOException.

Solutions

  1. Verify the file is a valid Stride package (.sdpkg) containing the Id: header line
  2. Re-save or re-export the package from Stride Game Studio
  3. Check the file is not truncated/corrupted (re-download or restore from VCS)

Example fix

// before
var id = Package.GetPackageIdFromFile(new UFile("notes.txt"));
// after
if (File.Exists(path) && new FileInfo(path).Length > 0 && path.EndsWith(".sdpkg"))
    var id = Package.GetPackageIdFromFile(new UFile(path));
Defensive patterns

Strategy: validation

Validate before calling

if (!File.Exists(path) || !path.EndsWith(".sdpkg")) throw new FileNotFoundException(path);

Try / catch

try { var id = Package.GetPackageIdFromFile(file); } catch (IOException ex) { log.Error($"Not a valid package: {ex.Message}"); }

Prevention

When it happens

Trigger: Calling GetPackageIdFromFile on a file that lacks the "Id:" header line, has a corrupted/truncated header, or is not a .sdpkg/package file at all.

Common situations: Pointing at an empty or placeholder file; a package saved by an incompatible/older version; a text file renamed to .sdpkg; a partially written/downloaded package.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/7dc74598c47b4208. Report an issue: GitHub.

Appendix: source

Thrown at sources/assets/Stride.Core.Assets/Package.cs:553

        bool hasPackage = false;
        using (var reader = new StreamReader(stream))
        {
            string? line;
            while ((line = reader.ReadLine()) is not null)
            {
                if (line.StartsWith("!Package", StringComparison.Ordinal))
                {
                    hasPackage = true;
                }

                if (hasPackage && line.StartsWith("Id:", StringComparison.Ordinal))
                {
                    var id = line["Id:".Length..].Trim();
                    return Guid.Parse(id);
                }
            }
        }
        throw new IOException($"File {filePath} doesn't appear to be a valid package");
    }

    /// <summary>
    /// Loads only the package description but not assets or plugins.
    /// </summary>
    /// <param name="log">The log to receive error messages.</param>
    /// <param name="filePath">The file path.</param>
    /// <param name="loadParametersArg">The load parameters argument.</param>
    /// <returns>A package.</returns>
    /// <exception cref="ArgumentNullException">log
    /// or
    /// filePath</exception>
    public static Package? Load(ILogger log, string filePath, PackageLoadParameters? loadParametersArg = null)
    {
        var package = LoadProject(log, filePath)?.Package;

        if (package?.LoadAssembliesAndAssets(log, loadParametersArg) == false)
        {

View on GitHub (pinned to 96fad776d2)