Remove duplicated profiles block from empty C# AppHost aspire.config.json#17781
Conversation
…json
The embedded CLI template src/Aspire.Cli/Templating/Templates/empty-apphost/aspire.config.json
shipped a profiles block that duplicated apphost.run.json. The canonical template in
src/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.json
intentionally has no profiles (per Damian's design): aspire run / dotnet run apphost.cs
honor apphost.run.json when present, so aspire.config.json for the C# Empty template
should only carry { "appHost": { "path": "apphost.cs" } }.
Updated NewCommandTests to:
- assert that aspire.config.json has no profiles block and pins appHost.path = apphost.cs
- assert that apphost.run.json carries the launch URLs (plain localhost and dev.localhost variants)
- drop the now-unused AssertHttpsApplicationUrlMatches helper
Fixes #17660
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 -- 17781Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 17781" |
|
❓ CLI E2E Tests unknown — 110 passed, 0 failed, 2 unknown (commit View all recordings
📹 Recordings uploaded automatically from CI run #26736967130 |
PR #17781 Testing ReportPR Information
CLI Version Verification
Changes AnalyzedFiles Changed
Change Categories
Test Scenarios ExecutedScenario 1: Plain
|
| Scenario | Status | Notes |
|---|---|---|
| 1. Plain localhost — file shape | ✅ Passed | aspire.config.json minimal; apphost.run.json carries profiles |
| 2. Localhost-TLD — file shape | ✅ Passed | TLD substitution lands in apphost.run.json only |
| 3. Runtime smoke | ✅ Passed | Dashboard bound at apphost.run.json port, HTTP 200, clean stop |
Overall Result
✅ PR VERIFIED
Issue #17660 is fixed. The empty C# AppHost template no longer duplicates launch-profile content across apphost.run.json and aspire.config.json — profiles live only in apphost.run.json, and aspire.config.json is the minimal canonical shape { "appHost": { "path": "apphost.cs" } }. Runtime behavior (aspire start / dashboard reachability) is unaffected.
Recommendations
- None for this PR.
- (Out of scope per author) Drift detection between
Aspire.Cli/Templating/Templates/empty-apphost/andAspire.ProjectTemplates/templates/aspire-apphost-singlefile/is worth considering separately — that divergence is what allowed this duplication to survive for several months.
There was a problem hiding this comment.
Pull request overview
This PR fixes a regression in the embedded Aspire CLI empty C# AppHost template where aspire.config.json redundantly carried a profiles block that is already provided via apphost.run.json (per #17660). The change aligns the embedded CLI template with the canonical single-file AppHost template behavior: aspire.config.json should only point at apphost.cs, while launch profiles live exclusively in apphost.run.json.
Changes:
- Removed the duplicated
profilesblock fromsrc/Aspire.Cli/Templating/Templates/empty-apphost/aspire.config.json, leaving only"appHost": { "path": "apphost.cs" }. - Updated
NewCommandTeststo assert thataspire.config.jsonhas noprofiles, and that URLs/profiles exist inapphost.run.json(includingdev.localhostbehavior). - Removed the now-obsolete test helper that compared HTTPS URLs between the two files.
Show a summary per file
| File | Description |
|---|---|
src/Aspire.Cli/Templating/Templates/empty-apphost/aspire.config.json |
Removes redundant launch profile configuration so the template relies on apphost.run.json as the single source of launch profiles. |
tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs |
Updates assertions to validate the new split of responsibilities: minimal aspire.config.json and launch URLs/profiles in apphost.run.json. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
JamesNK
left a comment
There was a problem hiding this comment.
Clean fix. The template change correctly removes the duplicated profiles block that's already in apphost.run.json, and the tests properly validate the new contract from multiple angles (plain localhost, dev.localhost TLD, and prompted TLD paths). No issues found.
|
/backport to release/13.4 |
|
Started backporting to |
The empty C# AppHost template (created with `aspire new`) stores launch profiles in `apphost.run.json`, not in `aspire.config.json`. The `aspire.config.json` for this template only contains the `appHost.path` reference pointing at `apphost.cs`. Update the AppHost configuration page to distinguish between: - Project-based AppHosts: profiles in `Properties/launchSettings.json` - File-based AppHosts: profiles in `apphost.run.json`, with `aspire.config.json` holding only the entry-point reference This aligns the documentation with the fix in microsoft/aspire#17781, which corrected a regression where the file-based template was incorrectly emitting a duplicate `profiles` block in `aspire.config.json`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Pull request created: #1176
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1176 targeting Updated Note This draft PR needs human review before merging. |
Description
Fixes #17660.
The embedded CLI template
src/Aspire.Cli/Templating/Templates/empty-apphost/aspire.config.jsonshipped aprofilesblock that duplicated the content already inapphost.run.json. The canonical template atsrc/Aspire.ProjectTemplates/templates/aspire-apphost-singlefile/aspire.config.jsonintentionally has noprofiles(per @DamianEdwards in the issue):aspire run/dotnet run apphost.cs/ C# Dev Kit honorapphost.run.jsonwhen present, soaspire.config.jsonfor the C# Empty template should only carry:{ "appHost": { "path": "apphost.cs" } }This was a regression introduced in the 13.4 cycle. In 13.3.5 only
aspire.config.jsonwas emitted; onceapphost.run.jsonwas added the embedded template was not trimmed to remove the now-duplicated profiles.Changes
src/Aspire.Cli/Templating/Templates/empty-apphost/aspire.config.json— removed theprofilesblock.tests/Aspire.Cli.Tests/Commands/NewCommandTests.cs— three tests previously asserted the duplicated content:…EmitsAppHostRunJson…tests now assertaspire.config.jsonhas noprofilesblock and that it pinsappHost.path = "apphost.cs", whileapphost.run.jsoncarries the launch URLs (plainlocalhostanddev.localhostvariants).…PromptsForLocalhostTld…test now asserts the dev-localhost URL lives inapphost.run.jsonand is absent fromaspire.config.json.AssertHttpsApplicationUrlMatcheshelper.Safety
DotNetAppHostProjectreadsapphost.run.jsonfirst and only falls back toaspire.config.json#profileswhenapphost.run.jsonis missing, so removing profiles from a template that shipsapphost.run.jsonis safe at runtime.ApplyLocalhostTldToScaffoldedRunProfileAsynconly runs for non-C# scaffolded templates (TypeScript / Python); the C# path applies tokens viaApplyAllTokensto all files includingapphost.run.json, so the localhost-TLD substitution still lands in the right file.tests/Aspire.Cli.EndToEnd.Tests/EmptyAppHostTemplateTests.CreateAndRunEmptyAppHostProjectrunsaspire new(C# Empty) →aspire start --format json→ curls the dashboard URL for HTTP 200 →aspire stop. If the new layout broke startup it would catch it.Tested
NewCommandTestspass locally.NewCommandTemplateConfigPersistenceTests+NewCommandChannelResolutionTestspass locally.Microsoft Reviewers: Open in CodeFlow