Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article applies to: ✔️ Aspire CLI 9.4.0 and later versions.
Note
This command is disabled by default. To use it, turn on the feature toggle by running:
aspire config set features.execCommandEnabled true
For more information, see aspire config command.
Name
aspire exec - Run an Aspire AppHost to execute a command against the resource.
Important
This command is in preview and subject to change.
Synopsis
aspire exec [options] [[--] <additional arguments>...]
Description
The aspire exec command runs a command in the context of one of the resources defined in the AppHost.
You must specify either the --resource or the --start-resource option, and you must provide parameters with the -- option.
The Aspire CLI uses the following logic, in order, to determine which AppHost project to process:
The
--projectoption.This option specifies the path to a project to process.
The
.aspire/settings.jsonconfig file.If the config file path exists in the current directory, it's used. If not, the CLI walks up the directory structure looking for the config file. If it finds a config file, it reads the
appHostPathsetting value as the project to process.Searches the current directory and subdirectories.
Starting in the current directory, the CLI gathers all AppHost projects from that directory and below. If a single project is discovered, it's automatically selected. If multiple projects are discovered, they're printed to the terminal for the user to manually select one of the projects.
Once a project is selected, either automatically or manually, the path to the project is stored in the
.aspire/settings.jsonconfig file.
Options
The following options are available:
--Delimits arguments to
aspire execfrom arguments for the resource. All arguments after this delimiter are passed to the resource.-
--projectThe path to the Aspire AppHost project file.
-r, --resourceThe name of the target resource to execute the command against.
-s, --start-resourceThe name of the target resource to start and execute the command against.
-
-?, -h, --helpPrints help and usage documentation for the available commands and options.
-
-d, --debugEnable debug logging to the console, which prints detailed information about what Aspire CLI is doing when a command is run.
-
--wait-for-debuggerWait for a debugger to attach before running a command.
Examples
Builds and runs the AppHost project, then sends the command
migrateto thedatabase1resource:aspire exec --resource database1 -- migrate