{"record":{"id":"ec58618ec60611dc","repo":"microsoft/aspire","slug":"embedded-resource-name-not-found-atsrustcodegenerator","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.Rust/AtsRustCodeGenerator.cs","lineNumber":73,"sourceCode":"                pub mod aspire;\n\n                pub use transport::*;\n                pub use base::*;\n                pub use aspire::*;\n                \"\"\",\n            [\"transport.rs\"] = GetEmbeddedResource(\"transport.rs\"),\n            [\"base.rs\"] = GetEmbeddedResource(\"base.rs\"),\n            [\"aspire.rs\"] = GenerateAspireSdk(context)\n        };\n    }\n\n    private static string GetEmbeddedResource(string name)\n    {\n        var assembly = Assembly.GetExecutingAssembly();\n        var resourceName = $\"Aspire.Hosting.CodeGeneration.Rust.Resources.{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    private string GenerateAspireSdk(AtsContext context)\n    {\n        using var stringWriter = new StringWriter(CultureInfo.InvariantCulture);\n        _writer = stringWriter;\n\n        var capabilities = context.Capabilities;\n        var dtoTypes = context.DtoTypes;\n        var enumTypes = context.EnumTypes;\n\n        _enumNames.Clear();\n        foreach (var enumType in enumTypes)\n        {\n            _enumNames[enumType.TypeId] = SanitizeIdentifier(enumType.Name);\n        }","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs#L55-L91","documentation":"The Rust code generator loads its template/runtime support files from embedded resources in the Aspire.Hosting.CodeGeneration.Rust assembly, using the namespace `Aspire.Hosting.CodeGeneration.Rust.Resources.{name}`. `GetEmbeddedResource` throws this InvalidOperationException when the requested resource name does not match any manifest resource in the assembly. Like the other embedded-resource errors, it signals a packaging/build problem rather than user input error.","triggerScenarios":"Calling GenerateDistributedApplication in the Rust generator when a template resource it requests was not embedded (file missing/renamed, csproj EmbeddedResource entry removed, or assembly built without resources).","commonSituations":"Custom builds that exclude .rs template files; a renamed resource folder breaking the expected namespace; unofficial or corrupted package installs.","solutions":["Rebuild from a clean state or reinstall the official Aspire.Hosting.CodeGeneration.Rust package so embedded resources are intact.","Confirm the requested resource file exists under the Rust Resources directory and is listed as `<EmbeddedResource>` in the project file.","Inspect the assembly's manifest resource names to find the actual name and fix a mismatch if building from source.","File an issue with the missing resource name if this occurs on an official package build."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"var hasRustResources = typeof(AtsRustCodeGenerator).Assembly\n  .GetManifestResourceNames()\n  .Any(n => n.StartsWith(\"Aspire.Hosting.CodeGeneration.Rust.Resources.\"));","typeGuard":null,"tryCatchPattern":"try {\n  string template = GetEmbeddedResource(name);\n} catch (InvalidOperationException ex) when (ex.Message.Contains(\"Embedded resource\")) {\n  // reinstall/rebuild before retrying generation\n}","preventionTips":["Keep Rust template files and EmbeddedResource csproj entries synchronized.","Clean-rebuild after renaming resource folders.","Prefer official package builds over custom stripped ones."],"tags":["rust","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"}