# DockerfileBuildAnnotation Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [DockerfileBuildAnnotation](/reference/api/csharp/aspire.hosting/dockerfilebuildannotation.md)
- Kind: `Methods`
- Members: `1`

Represents an annotation for customizing a Dockerfile build.

## MaterializeDockerfileAsync(DockerfileFactoryContext, CancellationToken)

- Name: `MaterializeDockerfileAsync(DockerfileFactoryContext, CancellationToken)`
- Returns: `Task`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/DockerfileBuildAnnotation.cs#L78-L106)

Materializes the Dockerfile from the factory if it hasn't been materialized yet. This method is thread-safe and ensures the Dockerfile is only written once.

```csharp
public class DockerfileBuildAnnotation
{
    public Task MaterializeDockerfileAsync(
        DockerfileFactoryContext context,
        CancellationToken cancellationToken)
    {
        // ...
    }
}
```

## Parameters

- `context` ([DockerfileFactoryContext](/reference/api/csharp/aspire.hosting/dockerfilefactorycontext.md))
  The context containing services and resource information.
- `cancellationToken` (`CancellationToken`)
  The cancellation token.

## Returns

`Task` -- A task representing the asynchronous operation.
