ContainerResourceBuilderExtensions.WithBuildArg Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
WithBuildArg<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>) |
Adds a build argument when the container is built from a Dockerfile. |
WithBuildArg<T>(IResourceBuilder<T>, String, Object) |
Adds a build argument when the container is build from a Dockerfile. |
WithBuildArg<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>)
Adds a build argument when the container is built from a Dockerfile.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithBuildArg<T> (this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string name, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> value) where T : Aspire.Hosting.ApplicationModel.ContainerResource;
static member WithBuildArg : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> * string * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.ApplicationModel.ParameterResource> -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)
<Extension()>
Public Function WithBuildArg(Of T As ContainerResource) (builder As IResourceBuilder(Of T), name As String, value As IResourceBuilder(Of ParameterResource)) As IResourceBuilder(Of T)
Type Parameters
- T
The type of container resource.
Parameters
- builder
- IResourceBuilder<T>
The resource builder for the container resource.
- name
- String
The name of the build argument.
The resource builder for a parameter resource.
Returns
The resource builder for the container resource.
Exceptions
Thrown when WithBuildArg<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>) is called before WithDockerfile<T>(IResourceBuilder<T>, String, String, String).
Examples
Adding a build argument based on a parameter..
var builder = DistributedApplication.CreateBuilder(args);
var branding = builder.AddParameter("branding");
builder.AddContainer("mycontainer", "myimage")
.WithDockerfile("../mycontainer")
.WithBuildArg("CUSTOM_BRANDING", branding);
Remarks
The WithBuildArg<T>(IResourceBuilder<T>, String, IResourceBuilder<ParameterResource>) extension method adds an additional build argument the container resource to be used when the image is built. This method must be called after WithDockerfile<T>(IResourceBuilder<T>, String, String, String).
Applies to
WithBuildArg<T>(IResourceBuilder<T>, String, Object)
Adds a build argument when the container is build from a Dockerfile.
public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithBuildArg<T> (this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, string name, object value) where T : Aspire.Hosting.ApplicationModel.ContainerResource;
static member WithBuildArg : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> * string * obj -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.ContainerResource)
<Extension()>
Public Function WithBuildArg(Of T As ContainerResource) (builder As IResourceBuilder(Of T), name As String, value As Object) As IResourceBuilder(Of T)
Type Parameters
- T
The type of container resource.
Parameters
- builder
- IResourceBuilder<T>
The resource builder for the container resource.
- name
- String
The name of the build argument.
- value
- Object
The value of the build argument.
Returns
The resource builder for the container resource.
Exceptions
Thrown when WithBuildArg<T>(IResourceBuilder<T>, String, Object) is called before WithDockerfile<T>(IResourceBuilder<T>, String, String, String).
Examples
Adding a static build argument.
var builder = DistributedApplication.CreateBuilder(args);
builder.AddContainer("mycontainer", "myimage")
.WithDockerfile("../mycontainer")
.WithBuildArg("CUSTOM_BRANDING", "/app/static/branding/custom");
Remarks
The WithBuildArg<T>(IResourceBuilder<T>, String, Object) extension method adds an additional build argument the container resource to be used when the image is built. This method must be called after WithDockerfile<T>(IResourceBuilder<T>, String, String, String).