microsoft/aspire · error · InvalidOperationException

Embedded runtime identifier graph resource

Error message

Embedded runtime identifier graph resource '{RuntimeIdentifierGraphResourceName}' was not found.

What it means

RestoreCommand needs the NuGet runtime identifier graph (runtime.json) to expand RID compatibility during restore. Normally it writes an embedded copy of that graph to disk; if the embedded manifest resource is missing from the assembly it throws an InvalidOperationException instead of silently restoring without RID graph data.

Solutions

  1. Rebuild/re-publish the application so the embedded runtime identifier graph resource is included in the assembly.
  2. Verify the embedded resource name matches RuntimeIdentifierGraphResourceName (check the csproj EmbeddedResource entries).
  3. If deploying, redeploy a complete build; do not strip embedded resources from the NuGet command assembly.

Example fix

// before
<ItemGroup>
  <None Include="runtime.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
// after
<ItemGroup>
  <EmbeddedResource Include="runtime.json" LogicalName="runtime.json" />
</ItemGroup>
Defensive patterns

Strategy: try-catch

Validate before calling

var hasGraph = typeof(RestoreCommand).Assembly.GetManifestResourceNames()
    .Contains(RestoreCommand.RuntimeIdentifierGraphResourceName);

Try / catch

try { var path = restoreCommand.RuntimeIdentifierGraphPath; }
catch (InvalidOperationException ex) when (ex.Message.Contains("runtime identifier graph"))
{ logger.LogCritical(ex, "Build is missing embedded RID graph; redeploy a complete build."); throw; }

Prevention

When it happens

Trigger: Calling runtimeIdentifierGraphPath when neither an on-disk graph file exists nor the assembly contains the embedded RuntimeIdentifierGraphResourceName resource — e.g. a broken or partially published build where embedded resources were stripped.

Common situations: Publishing with resource trimming/embedding disabled incorrectly, a packaging bug in a custom build, or the embedded resource name changed while a stale cached binary is still used.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/783624fa774d0e87. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Managed/NuGet/Commands/RestoreCommand.cs:341

        if (!string.IsNullOrWhiteSpace(runtimeIdentifier))
        {
            packageSpec.RuntimeGraph = new RuntimeGraph([new RuntimeDescription(runtimeIdentifier)]);
        }

        return packageSpec;
    }

    private static string EnsureRuntimeIdentifierGraphPath(string outputPath)
    {
        var graphPath = Path.Combine(outputPath, RuntimeIdentifierGraphFileName);
        if (File.Exists(graphPath))
        {
            return graphPath;
        }

        using var resourceStream = typeof(RestoreCommand).Assembly.GetManifestResourceStream(RuntimeIdentifierGraphResourceName)
            ?? throw new InvalidOperationException($"Embedded runtime identifier graph resource '{RuntimeIdentifierGraphResourceName}' was not found.");
        using var fileStream = File.Create(graphPath);
        resourceStream.CopyTo(fileStream);

        return graphPath;
    }
}

View on GitHub (pinned to 25830f84bd)