Optimize no-build AppHost project inspection#17246
Conversation
7304864 to
3559234
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17246Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17246" |
There was a problem hiding this comment.
Pull request overview
Centralizes .NET AppHost MSBuild inspection in the Aspire CLI to avoid repeated project evaluations (especially on aspire run/start --no-build), and adds a content-keyed disk cache so subsequent CLI runs can reuse prior inspection results when inputs haven’t changed.
Changes:
- Introduces an
AppHostInfoResolverthat coalesces MSBuild inspection in-memory (per CLI process) and optionally persists successful results to disk. - Adds an AppHost-info disk cache keyed by project path + relevant filesystem inputs, and wires it into CLI DI and
cache clear. - Updates CLI tests and test fakes to reflect the new single-probe inspection shape, and adds targeted coverage for resolver + disk cache behavior.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Utils/CliTestHelper.cs | Registers the resolver + a no-op disk cache for tests. |
| tests/Aspire.Cli.Tests/TestServices/TestDotNetCliRunner.cs | Extends the test runner to support async MSBuild probe callbacks and legacy-compat JSON synthesis. |
| tests/Aspire.Cli.Tests/TestServices/NullDiskCache.cs | Adds a no-op IAppHostInfoDiskCache implementation for tests. |
| tests/Aspire.Cli.Tests/Projects/DotNetAppHostProjectTests.cs | Adjusts expected MSBuild JSON shape to include AppHost detection properties. |
| tests/Aspire.Cli.Tests/Projects/AppHostInfoResolverTests.cs | New tests validating disk-cache hits, in-memory caching, concurrency coalescing, and cancellation semantics. |
| tests/Aspire.Cli.Tests/Commands/RunCommandTests.cs | Updates isolated user-secrets test to match the consolidated MSBuild response shape. |
| tests/Aspire.Cli.Tests/Commands/CacheCommandTests.cs | Adds coverage ensuring aspire cache clear removes the apphost-info cache directory. |
| tests/Aspire.Cli.Tests/Caching/AppHostInfoDiskCacheTests.cs | New tests for cache key stability/invalidation, disabled mode, and concurrent writes. |
| src/Aspire.Cli/Utils/AppHostHelper.cs | Extracts EvaluateAppHostCompatibility to allow compatibility gating without re-running MSBuild. |
| src/Aspire.Cli/Projects/DotNetAppHostProject.cs | Routes validation/compatibility/bundle/user-secrets probing through the shared resolver to avoid repeated MSBuild evaluations. |
| src/Aspire.Cli/Projects/AppHostInfoResolver.cs | New resolver implementing in-memory coalescing + disk-cache integration for AppHost project inspection. |
| src/Aspire.Cli/Program.cs | Registers the disk cache + resolver in CLI DI. |
| src/Aspire.Cli/JsonSourceGenerationContext.cs | Adds source-gen serialization metadata for the new cache/inspection payload types. |
| src/Aspire.Cli/Caching/AppHostInfoDiskCache.cs | New content-keyed disk cache implementation for AppHost inspection results. |
Copilot's findings
- Files reviewed: 14/14 changed files
- Comments generated: 4
|
Replying to the Copilot review overview: thanks for the overview. This is an automated summary of the PR with no actionable feedback, so no changes are required here. |
Centralize .NET AppHost MSBuild metadata inspection, coalesce per-process probes, and add a content-keyed disk cache so warm no-build startup can skip repeated project evaluations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9644659 to
0fea635
Compare
|
❓ CLI E2E Tests unknown — 94 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26170528351 |
|
See the workflow run for details: https://github.com/microsoft/aspire/actions/runs/26179694062 Drafted documentation updates for the AppHost info disk cache feature introduced in this PR. Three files were updated:
|
Description
aspire run --no-buildfor .NET AppHost projects was spending startup time re-evaluating the same AppHost MSBuild metadata multiple times before launching the AppHost. This change centralizes AppHost metadata resolution so each CLI process evaluates the project once, and then persists successful inspection results in a project-input disk cache for subsequent CLI runs.The resolver now owns the single source of truth for AppHost project metadata used by validation, compatibility checks, CLI bundle handoff, and isolated user-secrets cloning. The disk cache is keyed by the project path plus filesystem inputs that affect the evaluated MSBuild result, including the project file, restore assets file, conventional Directory.Build/Directory.Packages imports, global.json, and an explicit cache schema version. Writes use a random temp file plus atomic replace, and the resolver re-checks the cache key before publishing a result so a project edit during MSBuild evaluation cannot write stale metadata under a new key.
aspire cache clearremoves the AppHost info cache. Users can disable the disk cache with the normal Aspire config command:The toggle is read through Aspire config files/global config rather than environment variables. Disabling the disk cache still keeps the per-process in-memory coalescing, so a single CLI invocation does not regress to the original repeated MSBuild inspections.
Validation
dotnet build tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj /p:SkipNativeBuild=true --no-restoredotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-build --no-launch-profile -- --filter-class "*.AppHostInfoResolverTests" --filter-class "*.AppHostInfoDiskCacheTests" --filter-class "*.CacheCommandTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class "*.AppHostInfoDiskCacheTests" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"find_apphostFixes #17197
Checklist
<remarks />and<code />elements on your triple slash comments?