Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Running aspire new creates a project but no .aspire/settings.json file, causing the VS Code extension to immediately prompt for appHostPath configuration after opening the project.

Changes

Modified DotNetTemplateFactory.ApplyTemplateAsync to create .aspire/settings.json after successful template instantiation:

  • Added CreateSettingsFileAsync method that:
    • Searches output directory for AppHost projects (both .csproj and single-file apphost.cs)
    • Validates AppHost projects using existing GetAppHostInformationAsync infrastructure
    • Creates .aspire/settings.json with relative path to AppHost project
    • Uses JsonSourceGenerationContext for formatted output
    • Gracefully handles failures without breaking template creation

Example

Running aspire new aspire-starter --name MyApp --output ./myapp now creates:

./myapp/
├── .aspire/
│   └── settings.json          # New: {"appHostPath": "../MyApp.AppHost/MyApp.AppHost.csproj"}
├── MyApp.AppHost/
│   └── MyApp.AppHost.csproj
├── MyApp.Web/
└── MyApp.sln
Original prompt

This section details on the original issue you should resolve

<issue_title>aspire new should create a .aspire/settings.json file with appHostPath set after creation</issue_title>
<issue_description>This impacts the aspire extension as it will prompt you to set appHostPath immediately after opening the project</issue_description>

<agent_instructions>When running aspire new, if there is no existing appHostPath configuration setting the .aspire/settings.json file. If the file is created as part of aspire new then make sure that it is placed in the output directory and that the appHostPath is pointing to the right location relative to the location of the settings file.

It may be necessary to extract the existing logic that generates the appHostPath based on the working directory into a helper so that the base path can be overridden.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix aspire new to create settings.json with appHostPath Create .aspire/settings.json with appHostPath during aspire new Nov 12, 2025
Copilot AI requested a review from mitchdenny November 12, 2025 03:02
Copilot finished work on behalf of mitchdenny November 12, 2025 03:02
@github-actions
Copy link
Contributor

github-actions bot commented Nov 17, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12918

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12918"

@mitchdenny mitchdenny force-pushed the copilot/fix-settings-json-creation branch from b4c7824 to 411f4b5 Compare November 17, 2025 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aspire new should create a .aspire/settings.json file with appHostPath set after creation

2 participants