{"record":{"id":"265e83cf3936a64f","repo":"microsoft/aspire","slug":"embedded-resource-name-not-found-embeddedresources","errorCode":null,"errorMessage":"Embedded resource '{name}' not found.","messagePattern":"Embedded resource '(.+?)' not found\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.CodeGeneration.TypeScript/EmbeddedResources.cs","lineNumber":26,"sourceCode":"/// <c>Aspire.Hosting.CodeGeneration.TypeScript</c> assembly.\n/// </summary>\ninternal static class EmbeddedResources\n{\n    private const string ResourceNamespace = \"Aspire.Hosting.CodeGeneration.TypeScript.Resources\";\n\n    /// <summary>\n    /// Reads the contents of an embedded resource by file name (e.g. <c>\"eslint.config.mjs\"</c>).\n    /// </summary>\n    /// <param name=\"name\">The resource file name as it lives under <c>Resources/</c>.</param>\n    /// <returns>The UTF-8 text content of the resource.</returns>\n    /// <exception cref=\"InvalidOperationException\">Thrown when the resource is not embedded.</exception>\n    public static string Read(string name)\n    {\n        var assembly = typeof(EmbeddedResources).Assembly;\n        var resourceName = $\"{ResourceNamespace}.{name}\";\n\n        using var stream = assembly.GetManifestResourceStream(resourceName)\n            ?? throw new InvalidOperationException($\"Embedded resource '{name}' not found.\");\n        using var reader = new StreamReader(stream);\n        return reader.ReadToEnd();\n    }\n}\n","sourceCodeStart":8,"sourceCodeEnd":31,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.TypeScript/EmbeddedResources.cs#L8-L31","documentation":"The TypeScript code generator's EmbeddedResources.Read helper loads template files (like base.mts) from embedded resources in the assembly under the configured ResourceNamespace. It throws this InvalidOperationException when GetManifestResourceStream returns null, i.e. no embedded resource matches `{ResourceNamespace}.{name}`. This is an internal invariant failure indicating the assembly was built or packaged without its resource files.","triggerScenarios":"Invoking EmbeddedResources.Read (via code generation in GenerateDistributedApplication or related paths) with a name whose corresponding file is not embedded in the assembly — missing/renamed resource file, removed csproj EmbeddedResource entry, or stripped build.","commonSituations":"Running a locally modified or unofficial build of the package; a packaging regression that dropped Resources/*.mts; corrupt NuGet package cache after a partial download.","solutions":["Reinstall/restore the official package or clean-rebuild the repo so the embedded resources are included.","Verify the referenced resource file exists and is marked `<EmbeddedResource>` in the TypeScript code generation project.","Compare the assembly's manifest resource names with the ResourceNamespace constant to find naming mismatches when building from source.","Report the issue with the exact resource name if an official package build triggers it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const names = typeof(EmbeddedResources).Assembly.GetManifestResourceNames();\nconst exists = names.some(n => n === `${ResourceNamespace}.${name}`);","typeGuard":null,"tryCatchPattern":"try {\n  const template = EmbeddedResources.Read(name);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('Embedded resource')) {\n    // broken build/package; reinstall and report\n  }\n}","preventionTips":["Verify embedded resource names after any rename of Resources/*.mts files.","Clean-rebuild when switching between package versions.","Use official packages; avoid locally stripped builds."],"tags":["typescript","code-generation","embedded-resource","packaging"],"backgroundTag":"resource-not-found","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}