Repository navigation
Delegate bundled AppHost dotnet run to Aspire CLI - #17748
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17748Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17748" |
Use the platform-correct PATH environment variable name so the fake Aspire CLI shim is discoverable when dotnet run launches the AppHost run hook on Windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirror the Azure Functions dotnet run hook on Windows so PATH command shims like aspire.cmd resolve through cmd /C. Keep explicit AspireCliPath execution direct and update the SDK tests to expect the platform-specific run command shape. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Superseded by the updated PR testing report below. |
Teach the AppHost SDK run hook to pass the original apphost.cs path for file-based AppHosts and ensure CLI-launched file AppHosts suppress the hook without using the cached --no-build run path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
PR Testing ReportPR Information
CLI Version Verification
Changes AnalyzedFiles Changed
Change Categories
Test Scenarios ExecutedScenario 1: Project AppHost
|
| Scenario | Status | Notes |
|---|---|---|
Project AppHost dotnet run handoff |
✅ Passed | dotnet run delegates to Aspire CLI and starts cleanly. |
| File-based AppHost positional handoff | ✅ Passed | dotnet run apphost.cs delegates to Aspire CLI and forwards arguments. |
| Missing AppHost path | ✅ Passed | Clear non-zero validation failure. |
Direct aspire run in bundled mode |
✅ Passed | Project and file-based AppHosts start through direct CLI invocation. |
Direct aspire start/aspire stop in bundled mode |
✅ Passed | Project and file-based AppHosts start detached and stop cleanly. |
Overall Result
✅ PR VERIFIED
The PR build was verified against the latest tested head commit. Both project-based and file-based AppHost dotnet run scenarios now exercise the Aspire CLI handoff path, including the file-based positional form that previously failed. Direct aspire run and aspire start/aspire stop also continue to work in bundled mode.
There was a problem hiding this comment.
Pull request overview
Adds an AppHost SDK hook so dotnet run on an AppHost (when AspireUseCliBundle=true) delegates to the bundled aspire run. To prevent recursion (dotnet run → aspire run → dotnet run), the CLI's DotNetCliRunner sets ASPIRE_SUPPRESS_CLI_RUN_HOOK in the child env (and an MSBuild /p: for file-based AppHosts), and the targets honor either the env var or the _AspireSuppressCliRunHook property.
Changes:
- New
_AspireComputeRunArgumentsMSBuild target rewritesRunCommand/RunArguments/RunWorkingDirectoryto invokeaspire run --project <path> --no-build -- <originalArgs>, with Windows shim handling viacmd /C aspireand special-cased file-based AppHost path resolution. DotNetCliRunneralways propagatesASPIRE_SUPPRESS_CLI_RUN_HOOK=truein the run env, and additionally passes/p:ASPIRE_SUPPRESS_CLI_RUN_HOOK=trueon the file-baseddotnet run --filecommand-line (cached run args path).- Adds unit tests for the SDK targets and CLI runner, plus two end-to-end bundle smoke tests covering project and file-based AppHosts launched via
dotnet run.
Show a summary per file
| File | Description |
|---|---|
| src/Shared/KnownConfigNames.cs | Adds SuppressCliRunHook constant. |
| src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets | New _AspireComputeRunArguments target redirecting dotnet run to the Aspire CLI bundle. |
| src/Aspire.Cli/DotNet/DotNetCliRunner.cs | Sets suppression env var on all CLI-launched AppHosts; adds /p: switch on file-based dotnet run. |
| tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs | New SDK-targets tests covering bundle/non-bundle, suppression, file-based AppHost, and end-to-end dotnet run capture. |
| tests/Aspire.Cli.Tests/DotNet/DotNetCliRunnerTests.cs | Asserts suppression env var and /p: switch are emitted for project, file-based, and project-items code paths. |
| tests/Aspire.Cli.EndToEnd.Tests/BundleSmokeTests.cs | Adds E2E tests for dotnet run → aspire run for both project and file-based AppHosts. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 0
Allow the AppHost run hook suppression properties to accept 1 in addition to true, and clarify the single-file dotnet run cache workaround. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update the comment to explain that --no-build skips recomputing RunCommand, rather than implying /p: properties are ignored by the up-to-date check. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The test already uses fake time to prove the remaining startup budget is consumed. Remove the wall-clock assertion that can fail under Windows CI load. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
❓ CLI E2E Tests unknown — 112 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26829109093 |
|
David Fowler (@davidfowl) can we add a CLI E2E test to cover the |
Damian Edwards (DamianEdwards)
left a comment
There was a problem hiding this comment.
Just the comment about adding an E2E CLI case for this but that's non-blocking
|
Yep, we already have this covered in
The project-based test sets |
Description
dotnet runaspire run
dotnet runfor AppHosts should behave consistently with other Aspire bundle flows whenAspireUseCliBundleis enabled. This change lets the AppHost SDK take over MSBuild's run command and route the invocation throughaspire run, so bundled CLI behavior is used while still preserving app arguments.The full control flow is
dotnet run->aspire run->dotnet run: the outer user-facingdotnet rundelegates to the Aspire CLI, and the Aspire CLI then starts the AppHost usingdotnet runas usual. To avoid recursively re-entering the MSBuild run hook on that inner launch, the CLI setsASPIRE_SUPPRESS_CLI_RUN_HOOKwhile it probes and runs AppHosts. File-based AppHosts also pass the suppression property to the innerdotnet runinvocation so cached run arguments cannot bounce back toaspire run.The SDK target computes
RunCommandandRunArgumentsfordotnet runin bundle mode, appending original app arguments after--.User-facing usage
Project AppHosts with the bundle enabled can run through the Aspire CLI via
dotnet run:Internally this delegates to:
aspire run --project "MyApp.AppHost.csproj" --no-build -- --from-dotnet-runValidation:
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?