microsoft/aspire · error · DistributedApplicationException

The Rust app ' ' targets ' ', but the default Rust build…

Error message

The Rust app '{resource.Name}' targets '{target}', but the default Rust build image does not support container target platform '{platform}'. Configure buildImage with WithDockerfileBaseImage before publishing.

What it means

Aspire's Rust integration generates a Dockerfile at publish time. When a cargo target is specified (via WithCargoOptions target), the integration maps the target's architecture to a container platform and checks whether the default Rust build image (official Rust image, musl-based) supports that platform. The default build image only publishes amd64 and arm64 variants, so for other platforms (linux/arm, linux/386) the library throws at publish time unless you supply a custom build image with WithDockerfileBaseImage.

Solutions

  1. Configure a custom build image that supports the target platform: call WithDockerfileBaseImage(buildImage: "<image supporting your target>") on the Rust resource before publishing.
  2. If both build and runtime images are incompatible, configure both in a single WithDockerfileBaseImage(buildImage: ..., runtimeImage: ...) call — later calls replace the previous configuration entirely.
  3. If you don't actually need that cargo target (e.g. you are building for the host arch), remove or change the WithCargoOptions target to x86_64-unknown-linux-musl or aarch64-unknown-linux-musl so the default image works.
  4. For targets the platform mapper cannot handle (custom target JSON, non-Linux targets), author your own Dockerfile instead of relying on the generated one.

Example fix

// before
builder.AddRustApp("api", "../api")
    .WithCargoOptions(o => o.WithTarget("armv7-unknown-linux-musleabihf"));

// after
builder.AddRustApp("api", "../api")
    .WithCargoOptions(o => o.WithTarget("armv7-unknown-linux-musleabihf"))
    .WithDockerfileBaseImage(
        buildImage: "rust:1-bookworm",       // multi-arch builder supporting armv7 cross builds
        runtimeImage: "debian:bookworm-slim");
Defensive patterns

Strategy: validation

Validate before calling

// Before publishing, verify the cargo target maps to a default-supported platform
var target = "armv7-unknown-linux-musleabihf"; // your WithCargoOptions target
var parts = target.Split('-');
var arch = parts[0];
var supported = arch is "x86_64" or "aarch64" && parts[^1] == "musl";
if (!supported)
{
    // configure WithDockerfileBaseImage(buildImage: ...) before publishing
}

Try / catch

try
{
    // app host publish/run
}
catch (DistributedApplicationException ex) when (ex.Message.Contains("default Rust build image"))
{
    // surface guidance: configure WithDockerfileBaseImage(buildImage: ...) for this target
}

Prevention

When it happens

Trigger: Calling builder.AddRustApp(...).WithCargoOptions(o => o.WithTarget("armv7-unknown-linux-musleabihf")) (or any i386/i486/i586/i686/arm/armv4t/armv5te/armv7/thumbv7neon target) and then publishing (app host publish mode), without having called WithDockerfileBaseImage with a non-null buildImage. ResolveContainerTargetPlatform (called from FinalizePublishDockerfile) computes defaultBuildImageCompatible=false (platform not LinuxAmd64/LinuxArm64, or environment not musl) and customBuildImageConfigured=false.

Common situations: Cross-compiling a Rust app for 32-bit ARM devices (Raspberry Pi) or 32-bit x86 targets using the default images; upgrading the Aspire Rust integration when adding a non-amd64/arm64 target; forgetting WithDockerfileBaseImage when switching from a host-arch target to an embedded/ARM target.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Hosting.Rust/RustHostingExtensions.cs:914

        var baseImages = container.Annotations.OfType<DockerfileBaseImageAnnotation>().LastOrDefault()
            ?? resource.Annotations.OfType<DockerfileBaseImageAnnotation>().LastOrDefault();
        var customBuildImageConfigured = baseImages?.BuildImage is not null;
        var customRuntimeImageConfigured = baseImages?.RuntimeImage is not null;

        if (!defaultBuildImageCompatible && !defaultRuntimeImageCompatible
            && (!customBuildImageConfigured || !customRuntimeImageConfigured))
        {
            throw new DistributedApplicationException(
                $"The Rust app '{resource.Name}' targets '{target}', which is not compatible with the default " +
                "musl build and runtime images. Configure both images in a single " +
                "WithDockerfileBaseImage(buildImage: ..., runtimeImage: ...) call before publishing; later calls replace " +
                "the previous configuration.");
        }

        if (!defaultBuildImageCompatible && !customBuildImageConfigured)
        {
            throw new DistributedApplicationException(
                $"The Rust app '{resource.Name}' targets '{target}', but the default Rust build image does not support " +
                $"container target platform '{platform}'. Configure buildImage with WithDockerfileBaseImage before publishing.");
        }

        if (!defaultRuntimeImageCompatible && !customRuntimeImageConfigured)
        {
            throw new DistributedApplicationException(
                $"The Rust app '{resource.Name}' targets '{target}', but the default Rust runtime image is not compatible " +
                "with its target ABI. Configure runtimeImage with WithDockerfileBaseImage before publishing.");
        }

        return platform;
    }

    private static DistributedApplicationException CreateUnsupportedContainerTargetException(
        RustAppResource resource,
        string target)
        => new(

View on GitHub (pinned to 25830f84bd)