Repository navigation
Fix azd AppHost detection before restore - #22635
Karol Zadora-Przylecki (karolz-ms) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 22635Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 22635" |
Tests selector3 / 101 PR test projects · 3 PR jobs, from 5 changed files. Selected PR test projects (3 / 101)
Selected PR jobs (3)
How these were chosen — grouped by what changed🔧 🔧 🔧 🔧 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🔵 Needs a closer look
The packaged-template regression assertions have not run, and the reported pipeline failure remains unreproduced, requiring CI and human validation to confirm the fix addresses #22550.
No open issues 🎉
What changed in this PR
This PR makes generated C# AppHosts recognizable by azd before NuGet restore, addressing a detection gap that may explain #22550. Resource publishing and AddDotnetProject behavior remain unchanged.
Changes:
- Declare
IsAspireHostexplicitly in all four C# AppHost templates. - Add a regression theory checking pre-restore detection for each template.
- Document the identity requirement for existing projects migrating away from the AppHost SDK.
| File | Description |
|---|---|
| tests/Aspire.Templates.Tests/AppHostTemplateTests.cs | Adds pre-restore detection coverage for all four templates. |
| src/Aspire.ProjectTemplates/templates/aspire-ts-cs-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj | Declares AppHost identity in the TypeScript/C# starter. |
| src/Aspire.ProjectTemplates/templates/aspire-starter/Aspire-StarterApplication.1.AppHost/Aspire-StarterApplication.1.AppHost.csproj | Declares AppHost identity in the C# starter. |
| src/Aspire.ProjectTemplates/templates/aspire-empty/AspireApplication.1.AppHost/AspireApplication.1.AppHost.csproj | Declares AppHost identity in the empty solution template. |
| src/Aspire.ProjectTemplates/templates/aspire-apphost/Aspire.AppHost1.csproj | Declares AppHost identity in the standalone template. |
| docs/migrate-from-apphost-sdk.md | Explains explicit identity and the restore workaround. |
| docs/migrate-from-addproject.md | Distinguishes project identity from resource-registration migration. |
Review effort: Balanced
| NuGet imports have been generated. Declaring the property explicitly preserves detection | ||
| on clean CI agents. Otherwise, `azd provision` can treat the project as an ordinary .NET | ||
| service and look for a checked-in `infra/main.bicep` instead of generating infrastructure. | ||
| Restoring the AppHost before starting `azd` is a workaround for this detection gap. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |

Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
c6493b9154d315e073a6261e631bb4adeadacb12↑ Two existing AppHost SDK tests pass.
↓ The packaged-template regression test cannot initialize without the isolated test SDK; actual azd provisioning was not exercised.
infra/main.bicep.↓ The reporter's AppHost SDK, azd version, and pipeline restore order are unknown; the reported pipeline was not reproduced.
Description
Fix clean-checkout AppHost detection before NuGet restore so
azdcan generate Aspire infrastructure rather than falling back to a checked-ininfra/main.bicep. This fixes a detection gap that may explain the failure in #22550; the reporter's specific project and pipeline still need confirmation.The four C# AppHost templates now declare
IsAspireHostexplicitly. The migration guides explain the same requirement for existing projects, and a regression theory exercises azd's detection predicate on generated projects before restore. Resource publishing andAddDotnetProjectbehavior are unchanged.Fixes #22550
User-facing usage
Existing AppHosts migrated to
Microsoft.NET.Sdkcan make their identity available before restore:Restoring the AppHost before starting
azdis another workaround for this detection gap.Validation
dotnet msbuild <apphost.csproj> --ignore:.sln -nologo --getProperty:IsAspireHost --getItem:ProjectCapability: passed after the change; the same query failed to detect all four before it.dotnet build tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj --no-restore --verbosity quiet: passed.dotnet test --project tests/Aspire.Hosting.Sdk.Tests/Aspire.Hosting.Sdk.Tests.csproj --no-launch-profile -- --filter-method '*.PackagePropsDisableFileBasedAppHostAot' --filter-method '*.AppHostTargetsDefaultAspireHostingSDKVersionWhenSdkIsNotUsed' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true': passed, two tests.dotnet test --project tests/Aspire.Templates.Tests/Aspire.Templates.Tests.csproj --no-launch-profile -- --filter-method '*.AppHostIsDetectableBeforeRestore' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true': blocked; all four cases fail during harness initialization because the isolated template-test SDK is not installed. The regression assertions did not run.azd provisionand the reporter's pipeline were not run.Checklist
<remarks />and<code />elements on your triple slash comments?