aspire config set writes appHostPath to ~/.aspire/settings.json globally, causing incorrect path resolution#10700
Conversation
|
@copilot we are changing the strategy for solving this but. To remove ambiguity we are going to rename the global settings file from |
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Updated the code to rename the global settings file from The change is in commit 67cd7af. |
There was a problem hiding this comment.
Pull Request Overview
This PR addresses an issue where aspire config set incorrectly writes the appHostPath to the global settings file instead of local project settings. The problem occurs when the configuration service searches for existing settings files and mistakenly treats the global ~/.aspire/settings.json file as a local settings file when the project is located under the user's home directory.
- Changes the global settings file name from
settings.jsontoglobalsettings.jsonto avoid conflicts - Prevents the configuration service from treating global settings as local settings during path resolution
| var homeDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
| var globalSettingsPath = ConfigurationHelper.BuildPathToSettingsJsonFile(homeDirectory); | ||
| var globalSettingsPath = Path.Combine(homeDirectory, ".aspire", "globalsettings.json"); |
There was a problem hiding this comment.
Hardcoding the filename 'globalsettings.json' here creates a discrepancy with the ConfigurationHelper.BuildPathToSettingsJsonFile() method that was previously used. Consider creating a constant or method to ensure consistency across the codebase for the global settings filename.
|
/backport to release/9.4 |
|
Started backporting to release/9.4: https://github.com/dotnet/aspire/actions/runs/16572869923 |
Analyzing and fixing the issue where
aspire config setwritesappHostPathto global settings file instead of local project settings.Analysis
The issue occurs in the
ConfigurationService.FindNearestSettingsFile()method. Whenaspire runtries to create local settings with theappHostPath, the method walks up the directory tree looking for existing settings files. If the user's project is under their home directory, this search can find the global~/.aspire/settings.jsonfile and treat it as a "local" settings file, causing theappHostPathto be written globally instead of locally.Plan
ConfigurationService.FindNearestSettingsFile()Fixes #10699.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.