Skip to content
DocsTry Aspire
DocsTry

DockerfileBuildAnnotation Methods

ClassMethods2 members
Represents an annotation for customizing a Dockerfile build.
EmitDockerfileArtifactsAsync(DockerfileFactoryContext, string?)Section titled EmitDockerfileArtifactsAsync(DockerfileFactoryContext, string?)Task
Emits all generated Dockerfile artifacts for this annotation.
public class DockerfileBuildAnnotation
{
public Task EmitDockerfileArtifactsAsync(
DockerfileFactoryContext context,
string? dockerfilePath = null)
{
// ...
}
}
contextDockerfileFactoryContextThe context containing services and resource information.
dockerfilePathstring?optional The optional Dockerfile path to emit to. When specified, the materialized Dockerfile is copied to this path and any generated sibling files are emitted next to it. When omitted, artifacts are emitted next to DockerfileBuildAnnotation.DockerfilePath.
TaskA task representing the asynchronous operation.
This method materializes a Dockerfile from DockerfileBuildAnnotation.DockerfileFactory when present, then emits generated companion files such as BuildKit's per-Dockerfile .dockerignore sibling. Use this instead of calling DockerfileBuildAnnotation.MaterializeDockerfileAsync directly when the caller intends to pass the resulting Dockerfile path to a Docker/BuildKit-compatible builder.
MaterializeDockerfileAsync(DockerfileFactoryContext, CancellationToken)Section titled MaterializeDockerfileAsync(DockerfileFactoryContext, CancellationToken)Task
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.
public class DockerfileBuildAnnotation
{
public Task MaterializeDockerfileAsync(
DockerfileFactoryContext context,
CancellationToken cancellationToken)
{
// ...
}
}
contextDockerfileFactoryContextThe context containing services and resource information.
cancellationTokenCancellationTokenThe cancellation token.
TaskA task representing the asynchronous operation.