Add DNX AppHost CLI invocation opt-in - #18331
David Fowler (davidfowl) wants to merge 1 commit into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18331Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18331" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR adds an opt-in AspireCliInvocationMode=Dnx mode to the AppHost SDK targets, allowing an AppHost's dotnet run to route its launch through the repo-local Aspire.Cli .NET tool via dnx instead of requiring a global aspire command on PATH. The default PATH-based behavior and the explicit AspireCliPath override are preserved, and the build-time CLI bundle metadata is allowed to be absent only in DNX mode when no explicit CLI/bundle path was configured (the launching CLI injects DCP/Dashboard paths at runtime).
Changes:
- Adds
_AspireCliInvocationMode/_AspireUseDnxCliRunHook/_AspireCliDnxPackageIdplumbing and DNX-specificRunCommand/RunArguments(dnx aspire.cli -- run ..., deliberately withoutdnx -y) inAspire.Hosting.AppHost.in.targets. - Makes the
ASPIRE009error and the orchestration/dashboard discovery-attribute targets conditional on_AspireCliBundleResolutionOptionalso DNX mode tolerates a missing build-time bundle, while explicit invalid paths still fail. - Adds unit/integration coverage for the new run-command computation (including case-insensitive mode) and the bundle-resolution-optional behavior.
Show a summary per file
| File | Description |
|---|---|
src/Aspire.Hosting.AppHost/build/Aspire.Hosting.AppHost.in.targets |
Introduces the DNX invocation mode, its run-command/args, and the optional bundle-resolution gating of ASPIRE009 and discovery targets. |
tests/Aspire.Hosting.Sdk.Tests/AppHostSdkTargetsTests.cs |
Adds tests asserting the computed RunCommand/RunArguments for DNX mode (case-insensitive) and the AspireCliPath override precedence. |
tests/Aspire.Hosting.Tests/MSBuildTests.cs |
Adds tests that DNX mode allows a missing build-time bundle yet still fails ASPIRE009 when an explicit invalid AspireCliBundlePath is provided. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 0
|
If you're requiring a tool, devs will increasingly use a tool manifest to keep dev environments consistent. As such, you also need the aspire upgrade motion to update the tool manifest (it might already, sorry on phone). |
This comment has been minimized.
This comment has been minimized.
Introduce an opt-in AppHost CLI invocation mode that uses DNX to run the repo-local Aspire CLI package while preserving the existing PATH-based default. Add a preflight ASPIRE011 diagnostic when DNX mode is selected but the dnx command is unavailable, while keeping explicit AspireCliPath overrides working. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
61be9b3 to
cfd95f5
Compare
Tests selector (audit mode)The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement. 40 / 97 test projects · 2 jobs, from 5 changed files. Selected test projects (40 / 97)
Selected jobs (2)
How these were chosen — grouped by what changed
🔧 show 38
📦 affected project 🧪 🧪 🧪 Job reasons
Selection computed for commit |
| private static string GetAspireTasksAssemblyPath() | ||
| { | ||
| #if DEBUG | ||
| const string configuration = "Debug"; | ||
| #else | ||
| const string configuration = "Release"; | ||
| #endif | ||
| return Path.Combine(GetRepoRoot(), "artifacts", "bin", "Aspire.Hosting.Tasks", configuration, "net8.0", "Aspire.Hosting.Tasks.dll"); | ||
| } |
Description
This explores a safer opt-in path for AppHosts that need the Aspire CLI bundle without requiring a global
aspirecommand on PATH. The newAspireCliInvocationMode=Dnxmode lets a repo route AppHost launch through the repo-localAspire.Cli.NET tool package when that tool has been restored.User-facing usage
Projects can opt in with:
With
Aspire.Clideclared in the repo's local tool manifest and restored,dotnet runcomputes a launch command shaped like:dnx aspire.cli -- run --project "<AppHost>" --no-build -- ...This intentionally does not pass
dnx -y. A restored local tool manifest runs without prompting; a missing or unrestored tool fails with the .NET local-tool restore message instead of silently downloading and running an ad-hoc package.Implementation notes
AspireCliPathas the highest-precedence explicit override.AspireCliPathorAspireCliBundlePathwas configured. The launching CLI remains responsible for injecting DCP/Dashboard paths at runtime.ASPIRE009.Security considerations
This adds an opt-in process-spawning path through
dnx, which can execute a repo-declared local tool afterdotnet tool restore. The implementation avoidsdnx -yso AppHost launch does not silently install or execute an ad-hoc package when the manifest/tool is missing.Validation
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?