Skip to content
DocsTry Aspire
DocsTry

ExecutableResourceBuilderExtensions Methods

ClassMethods7 members
Provides extension methods for adding executable resources to the IDistributedApplicationBuilder application model.
AddExecutable(IDistributedApplicationBuilder, string, string, string, string[]?)Section titled AddExecutable(IDistributedApplicationBuilder, string, string, string, string[]?)extensionIResourceBuilder<ExecutableResource>
Adds an executable resource to the application model.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<ExecutableResource> AddExecutable(
this IDistributedApplicationBuilder builder,
string name,
string command,
string workingDirectory,
params string[]? args)
{
// ...
}
}
namestringThe name of the resource.
commandstringThe executable path. This can be a fully qualified path or a executable to run from the shell/command line.
workingDirectorystringThe working directory of the executable.
argsstring[]?The arguments to the executable.
IResourceBuilder<ExecutableResource>The ApplicationModel.IResourceBuilder`1.
You can run any executable command using its full path. As a security feature, Aspire doesn't run executable unless the command is located in a path listed in the PATH environment variable. To run an executable file that's in the current directory, specify the full path or use the relative path ./ to represent the current directory.
AddExecutable(IDistributedApplicationBuilder, string, string, string, object[]?)Section titled AddExecutable(IDistributedApplicationBuilder, string, string, string, object[]?)extensionIResourceBuilder<ExecutableResource>
Adds an executable resource to the application model.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<ExecutableResource> AddExecutable(
this IDistributedApplicationBuilder builder,
string name,
string command,
string workingDirectory,
params object[]? args)
{
// ...
}
}
namestringThe name of the resource.
commandstringThe executable path. This can be a fully qualified path or a executable to run from the shell/command line.
workingDirectorystringThe working directory of the executable.
argsobject[]?The arguments to the executable.
IResourceBuilder<ExecutableResource>The ApplicationModel.IResourceBuilder`1.
This method is not available in polyglot app hosts. Use the string[] overload instead.
Adds annotation to ExecutableResource to support containerization during deployment.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<T> PublishAsDockerFile<T>(
this IResourceBuilder<T> builder)
{
// ...
}
}
builderIResourceBuilder<T>Resource builder
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
PublishAsDockerFile(IResourceBuilder<T>, IEnumerable<DockerBuildArg>)Section titled PublishAsDockerFile(IResourceBuilder<T>, IEnumerable<DockerBuildArg>)extensionIResourceBuilder<T>
Adds annotation to ExecutableResource to support containerization during deployment. The resulting container image is built, and when the optional buildArgs are provided they're used with docker build --build-arg.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<T> PublishAsDockerFile<T>(
this IResourceBuilder<T> builder,
IEnumerable<DockerBuildArg>? buildArgs)
{
// ...
}
}
builderIResourceBuilder<T>Resource builder
buildArgsIEnumerable<DockerBuildArg>The optional build arguments, used with docker build --build-args.
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
PublishAsDockerFile(IResourceBuilder<T>, Action<IResourceBuilder<ContainerResource>>)Section titled PublishAsDockerFile(IResourceBuilder<T>, Action<IResourceBuilder<ContainerResource>>)extensionIResourceBuilder<T>
Adds support for containerizing this ExecutableResource during deployment. The resulting container image is built, and when the optional configure action is provided, it is used to configure the container resource.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<T> PublishAsDockerFile<T>(
this IResourceBuilder<T> builder,
Action<IResourceBuilder<ContainerResource>>? configure)
{
// ...
}
}
builderIResourceBuilder<T>Resource builder
configureAction<IResourceBuilder<ContainerResource>>Optional action to configure the container resource
IResourceBuilder<T>A reference to the ApplicationModel.IResourceBuilder`1.
When the executable resource is converted to a container resource, the arguments to the executable are not used. This is because arguments to the executable often contain physical paths that are not valid in the container. The container can be set up with the correct arguments using the configure action.
Sets the command for the executable resource.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<T> WithCommand<T>(
this IResourceBuilder<T> builder,
string command)
{
// ...
}
}
builderIResourceBuilder<T>Builder for the executable resource.
commandstringCommand.
IResourceBuilder<T>The ApplicationModel.IResourceBuilder`1.
WithWorkingDirectory(IResourceBuilder<T>, string)Section titled WithWorkingDirectory(IResourceBuilder<T>, string)extensionIResourceBuilder<T>
Sets the working directory for the executable resource.
public static class ExecutableResourceBuilderExtensions
{
public static IResourceBuilder<T> WithWorkingDirectory<T>(
this IResourceBuilder<T> builder,
string workingDirectory)
{
// ...
}
}
builderIResourceBuilder<T>Builder for the executable resource.
workingDirectorystringWorking directory.
IResourceBuilder<T>The ApplicationModel.IResourceBuilder`1.