{"record":{"id":"edd1fbf4cc653440","repo":"microsoft/aspire","slug":"the-published-rust-app-resource-name-was-not-converted-to-a","errorCode":null,"errorMessage":"The published Rust app '{resource.Name}' was not converted to a Dockerfile container resource.","messagePattern":"The published Rust app '(.+?)' was not converted to a Dockerfile container resource\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Rust/RustHostingExtensions.cs","lineNumber":153,"sourceCode":"        // on resource name and therefore finds the substituted container's build steps.\n        resourceBuilder.WithPipelineConfiguration(context =>\n        {\n            if (resource.TryGetAnnotationsOfType<ContainerFilesDestinationAnnotation>(out var containerFilesAnnotations))\n            {\n                var buildSteps = context.GetSteps(resource, WellKnownPipelineTags.BuildCompute);\n                foreach (var containerFile in containerFilesAnnotations)\n                {\n                    buildSteps.DependsOn(context.GetSteps(containerFile.Source, WellKnownPipelineTags.BuildCompute));\n                }\n            }\n        });\n\n        if (builder.ExecutionContext.IsPublishMode)\n        {\n            if (!builder.TryCreateResourceBuilder<ContainerResource>(resource.Name, out var containerBuilder)\n                || !containerBuilder.Resource.TryGetLastAnnotation<DockerfileBuildAnnotation>(out var provisionalDockerfile))\n            {\n                throw new InvalidOperationException(\n                    $\"The published Rust app '{resource.Name}' was not converted to a Dockerfile container resource.\");\n            }\n\n            var publishState = new RustPublishState();\n            containerBuilder.WithContainerBuildOptions(context =>\n            {\n                if (publishState.TargetPlatform is { } targetPlatform)\n                {\n                    context.TargetPlatform = targetPlatform;\n                }\n            });\n\n            builder.OnBeforeStart((_, _) =>\n            {\n                FinalizePublishDockerfile(builder, resource, provisionalDockerfile, publishState);\n                return Task.CompletedTask;\n            });\n        }","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Rust/RustHostingExtensions.cs#L135-L171","documentation":"In publish mode, AddRustApp must transform the RustAppResource into a Dockerfile-based ContainerResource carrying the provisional DockerfileBuildAnnotation. If TryCreateResourceBuilder<ContainerResource> fails or the annotation is missing, the publish pipeline cannot produce the container and this InvalidOperationException is thrown.","triggerScenarios":"Publishing an app whose model contains a Rust resource that was not converted — e.g. the resource name collides with another resource so builder lookup fails, model transformation was skipped, or a custom IResource transformation removed the DockerfileBuildAnnotation.","commonSituations":"Custom publish callbacks that rebuild/remove resources; duplicate resource names; calling publish APIs against a resource created outside AddRustApp; interrupted model transformation.","solutions":["Check for duplicate resource names in the AppHost (two builders with resource.Name).","Remove or fix custom transformation callbacks that delete or replace the Rust resource before FinalizePublishDockerfile runs.","Create the resource via AddRustApp so the provisional DockerfileBuildAnnotation is added.","Inspect the published model to confirm a ContainerResource with that name exists before publishing."],"exampleFix":"// before\nvar rust = builder.AddRustApp(\"api\", ...); builder.AddRustApp(\"api\", ...); // duplicate name breaks lookup\n// after\nvar rust = builder.AddRustApp(\"api\", ...);","handlingStrategy":"validation","validationCode":"if (builder.Resources.Select(r => r.Name).GroupBy(n => n).Any(g => g.Count() > 1))\n    throw new InvalidOperationException(\"Duplicate resource names prevent Rust publish conversion\");","typeGuard":null,"tryCatchPattern":"try { appBuilder.Build().Run(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"was not converted to a Dockerfile container resource\")) {\n    logger.LogError(\"Check publish transformations and resource name uniqueness\");\n}","preventionTips":["Keep resource names unique","Create Rust resources only via AddRustApp","Review custom publish transformations for resource removal"],"tags":["publish","dockerfile","resource-model","rust"],"backgroundTag":"invalid-state-transition","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"}