Skip to content

Add aspire dashboard CLI command and introduce unified IProcessExecutionFactory#15607

Open
JamesNK wants to merge 5 commits intomainfrom
cli-dashboard-command
Open

Add aspire dashboard CLI command and introduce unified IProcessExecutionFactory#15607
JamesNK wants to merge 5 commits intomainfrom
cli-dashboard-command

Conversation

@JamesNK
Copy link
Copy Markdown
Member

@JamesNK JamesNK commented Mar 26, 2026

Description

Add a new aspire dashboard CLI command that starts a standalone Aspire Dashboard instance using the aspire-managed binary from the CLI bundle, and refactor the process execution infrastructure to support both dotnet CLI and non-dotnet processes through a single abstraction.

aspire dashboard command

  • Runs the dashboard in the foreground, blocking until Ctrl+C, with a readiness check (waits for "Now listening on:" output)
  • Displays a summary panel with dashboard URL, OTLP gRPC/HTTP endpoints, and log file path
  • Generates a browser token for frontend authentication by default (passed via environment variable to avoid exposure in process listings)
  • Supports typed options: --frontend-url, --otlp-grpc-url, --otlp-http-url, --allow-anonymous, --config-file-path
  • Forwards unmatched tokens directly to the dashboard process for pass-through configuration
  • Respects configuration set via environment variables or unmatched --KEY=value / --KEY value tokens, skipping defaults when already provided
  • Handles dashboard-specific exit codes (unexpected error, validation failure, address in use) with localized error messages
  • Categorized under the Monitoring help group

Unified process execution infrastructure

  • Renamed IDotNetCliExecutionFactoryIProcessExecutionFactory and IDotNetCliExecutionIProcessExecution to reflect that process execution is no longer dotnet-specific
  • Renamed DotNetCliExecutionProcessExecution and deleted the old DotNetCliExecutionFactory
  • Moved dotnet-specific environment setup (orphan detection, MSBUILDTERMINALLOGGER, DOTNET_NOLOGO, private SDK resolution) from DotNetCliExecutionFactory into DotNetCliRunner, keeping IProcessExecutionFactory generic
  • Added Kill(bool entireProcessTree) and IDisposable to IProcessExecution so callers can manage process lifetime
  • Renamed DotNetCliRunnerInvocationOptionsProcessInvocationOptions
  • Changed LayoutProcessRunner from a static helper using raw System.Diagnostics.Process to an instance class that delegates to IProcessExecutionFactory, making it testable via DI
  • ProcessExecutionFactory now accepts a fileName parameter so it can launch any executable, not just dotnet

Dashboard exit code tests

  • Added StartupTests.Run_AddressAlreadyInUse_ReturnsExitCodeAddressInUse and Run_ValidationFailure_ReturnsNegativeOne to verify dashboard exit code behavior

Validation

  • All 21 DashboardCommandTests pass, covering default args, individual options (Theory), combined options, unmatched token forwarding, browser token generation, and process error handling
  • All existing CLI tests pass with the renamed types

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings March 26, 2026 06:32
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15607

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15607"

@JamesNK JamesNK marked this pull request as draft March 26, 2026 06:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new aspire dashboard top-level CLI command to launch the standalone Aspire Dashboard via the bundled aspire-managed binary, integrating it into the root command set and localized resources.

Changes:

  • Registers a new DashboardCommand in the CLI host and root command, categorized under the Monitoring help group.
  • Implements foreground and --detach execution paths and introduces localized resource strings for the new command.
  • Adds initial unit tests covering --help and the “bundle not available” error case.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs Registers DashboardCommand in the test DI container.
tests/Aspire.Cli.Tests/Commands/DashboardCommandTests.cs Adds tests for help and missing-bundle error behavior.
src/Aspire.Cli/Program.cs Registers DashboardCommand in the production DI container.
src/Aspire.Cli/Commands/RootCommand.cs Adds dashboard as a root subcommand.
src/Aspire.Cli/Commands/DashboardCommand.cs Implements the new aspire dashboard command (foreground/detach + arg pass-through).
src/Aspire.Cli/Resources/DashboardCommandStrings.resx Adds new localized strings for the dashboard command.
src/Aspire.Cli/Resources/DashboardCommandStrings.Designer.cs Strongly-typed accessor for the new dashboard strings.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.cs.xlf Localization XLF for cs.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.de.xlf Localization XLF for de.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.es.xlf Localization XLF for es.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.fr.xlf Localization XLF for fr.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.it.xlf Localization XLF for it.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.ja.xlf Localization XLF for ja.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.ko.xlf Localization XLF for ko.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.pl.xlf Localization XLF for pl.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.pt-BR.xlf Localization XLF for pt-BR.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.ru.xlf Localization XLF for ru.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.tr.xlf Localization XLF for tr.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.zh-Hans.xlf Localization XLF for zh-Hans.
src/Aspire.Cli/Resources/xlf/DashboardCommandStrings.zh-Hant.xlf Localization XLF for zh-Hant.
Files not reviewed (1)
  • src/Aspire.Cli/Resources/DashboardCommandStrings.Designer.cs: Language not supported

@MermaidIsla
Copy link
Copy Markdown
Contributor

Would it make sense to have an alias aspire dash ?

@KalleOlaviNiemitalo
Copy link
Copy Markdown

To me, aspire dash sounds too much like it would run a dash shell.

@JamesNK JamesNK force-pushed the cli-dashboard-command branch from 56a4214 to 2514d2c Compare March 30, 2026 12:57
@JamesNK JamesNK changed the title Add 'aspire dashboard' CLI command Add aspire dashboard CLI command and introduce unified IProcessExecutionFactory Mar 30, 2026
- Dispose IProcessExecution in DotNetCliRunner.ExecuteAsync to prevent handle leaks
- Check Start() return value in LayoutProcessRunner and throw on failure
- Use OptionResult.Implicit to avoid emitting default bool option values
- Recognize bare --KEY tokens (boolean flags) in ConfigSettingHasValue
- Add tests for bare-key and implicit-default behaviors
@JamesNK JamesNK marked this pull request as ready for review March 30, 2026 13:33
@JamesNK JamesNK requested a review from adamint as a code owner March 30, 2026 13:33
- Add bounds check on Split result to prevent IndexOutOfRangeException
  when ASPNETCORE_URLS is empty or contains only semicolons
- Add ResolveSettingValue method that checks args, unmatched tokens, and
  env vars so the summary URL reflects the actual dashboard binding
- Add parameterized tests for frontend URL variants and env var/token
  resolution
- Rename StartupTests validation failure test to match exit code naming
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit bdcac12)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23749387829

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants