# RustAppResource.WithCargoTarget

- Module: [Aspire.Hosting.Rust](/reference/api/go/aspire.hosting.rust.md)
- Defined on: [RustAppResource](/reference/api/go/aspire.hosting.rust/rustappresource.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`

Configures the target triple cargo builds for.

## Remarks

Passed to cargo as `--target`. Cargo writes a cross-compiled binary to
`target/<triple>/<profile>/`, and the generated Dockerfile follows that layout and adds
the target's standard library to the build image with `rustup target add`.
Aspire-generated Dockerfiles map native Linux x86_64, aarch64, 32-bit ARM, and 32-bit x86 targets to
Docker Linux platforms. Docker's `linux/arm` platform represents the ARMv7 variant. The default
build and runtime images support x86_64 and aarch64 musl targets. A 32-bit musl target needs a custom
build image but can use the default runtime image. Other ABIs require custom build and runtime images
configured together in one `WithDockerfileBaseImage` call because later calls replace the previous
image configuration.
Custom images opt out of default-image compatibility checks, but the target must still map to a
supported native Docker Linux platform. A custom build image must already contain any linker or
native dependencies the target needs; `WithDockerfileBaseImage` changes images but does not
install cross-compilation tooling. Other targets require an authored Dockerfile for publishing.

## Definition

```go
type RustAppResource interface {
    // ... omitted for brevity
    WithCargoTarget(target string) RustAppResource
}
```

## Signature

```go
WithCargoTarget(target string) RustAppResource
```

## Parameters

- `target` (`string`) -- The target triple, for example `x86_64-unknown-linux-musl`.

## Returns

[`RustAppResource`](/reference/api/go/aspire.hosting.rust/rustappresource.md) -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [RustAppResource](/reference/api/go/aspire.hosting.rust/rustappresource.md) -- `handle`
