Error in InitCommand when solution and project file are in the same directory#14963
Merged
JamesNK merged 2 commits intorelease/13.2from Mar 6, 2026
Merged
Error in InitCommand when solution and project file are in the same directory#14963JamesNK merged 2 commits intorelease/13.2from
JamesNK merged 2 commits intorelease/13.2from
Conversation
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 14963Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 14963" |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an aspire init failure mode where placing a solution file and a project file in the same directory would cause AppHost/ServiceDefaults to be generated under an existing project directory (an unsupported layout), by adding an early validation with a localized error.
Changes:
- Added an early guard in
InitCommand.InitializeExistingSolutionAsyncto detect*.{cs,fs,vb}projfiles in the solution directory and exit with a localized error. - Reused the .NET project extension list from
DotNetAppHostProjectby widening its visibility tointernal. - Added unit tests covering the failure case for
.csproj/.fsproj/.vbprojand a “no project files present” success path; added the new localized string to resx + xlf files.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Cli.Tests/Commands/InitCommandTests.cs | Adds tests for the new validation guard (error and success scenarios). |
| src/Aspire.Cli/Commands/InitCommand.cs | Adds the early validation check and localized error display. |
| src/Aspire.Cli/Projects/DotNetAppHostProject.cs | Exposes project extensions list as internal for reuse. |
| src/Aspire.Cli/Resources/InitCommandStrings.resx | Adds localized string for the new validation error. |
| src/Aspire.Cli/Resources/InitCommandStrings.Designer.cs | Updates strongly-typed resource accessor for the new string. |
| src/Aspire.Cli/Resources/xlf/InitCommandStrings.*.xlf | Adds the new resource id across translation files. |
Files not reviewed (1)
- src/Aspire.Cli/Resources/InitCommandStrings.Designer.cs: Language not supported
Contributor
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #22701425017 |
davidfowl
approved these changes
Mar 6, 2026
eerhardt
pushed a commit
to eerhardt/aspire
that referenced
this pull request
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When running
aspire init, if the solution file and a project file (.csproj,.fsproj, or.vbproj) are in the same directory, the AppHost and ServiceDefaults project directories would be created inside that existing project directory, which is not supported.This change adds an early validation check in
InitCommand.InitializeExistingSolutionAsyncthat detects this situation and exits with a clear error message telling the user to move the solution file to a parent directory or the project file to a subdirectory.Fixes #14841
Changes:
InitCommandto check for project files in the solution directory before proceedingDotNetAppHostProject.s_projectExtensions(madeinternal) for consistent extension matchingSolutionAndProjectInSameDirectoryto resource files and all xlf translationsChecklist