-
Notifications
You must be signed in to change notification settings - Fork 745
Various fixes to aspire update #13364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Enhanced FallbackProjectParserTests to validate extraction of SDK version from new project format. - Added tests for migrating from old SDK format to new format in ProjectUpdaterTests. - Implemented logic to remove obsolete Aspire.Hosting.AppHost package reference during SDK updates. - Ensured preservation of other SDKs in project attributes during updates.
- Introduced multiple test cases to verify the migration from old SDK format to new format. - Added tests to ensure the preservation of other SDKs in the attribute and the removal of obsolete package references. - Implemented checks for the correct updating of existing new format SDKs and the removal of empty ItemGroups after package removal. - Verified that similar SDK names do not match and are handled correctly during the update process.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13364Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13364" |
… adjust package assertions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances the Aspire CLI update command to support the new SDK-style project format (<Project Sdk="Aspire.AppHost.Sdk/version">) and automatically migrates projects from the old format during updates. The changes include parsing improvements, automatic migration logic, removal of the obsolete Aspire.Hosting.AppHost package reference, and informative user messages during migration.
Key Changes:
- Added support for parsing and updating the new SDK attribute format with version (e.g.,
Aspire.AppHost.Sdk/13.0.1) - Implemented automatic migration from old
<Sdk Name="...">element format to newSdkattribute format - Added removal of obsolete
Aspire.Hosting.AppHostpackage reference during updates - Added localized user-facing messages for migration actions
Reviewed changes
Copilot reviewed 37 out of 38 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.cs |
Updated existing tests to reflect that Aspire.Hosting.AppHost is no longer updated (removed during SDK migration); added 6 new comprehensive test cases for SDK migration scenarios |
tests/Aspire.Cli.Tests/Projects/ProjectUpdaterTests.*.verified.xml |
Snapshot verification files for new migration test cases showing expected XML output after transformations |
tests/Aspire.Cli.Tests/Projects/FallbackProjectParserTests.cs |
Modernized test infrastructure to use TemporaryWorkspace and async/await; added 4 new tests for new SDK format parsing |
tests/Aspire.Cli.Tests/Projects/FallbackProjectParserTests.*.verified.json |
Snapshot verification files for parser tests showing expected JSON output |
src/Aspire.Cli/Resources/UpdateCommandStrings.resx |
Added two new user-facing messages: MigratedToNewSdkFormat and RemovedObsoleteAppHostPackage |
src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs |
Auto-generated designer code synchronized with new resource strings |
src/Aspire.Cli/Resources/xlf/UpdateCommandStrings.*.xlf |
Localization files updated with new strings marked for translation (state="new") |
src/Aspire.Cli/Projects/ProjectUpdater.cs |
Core implementation: added migration detection, SDK attribute parsing/updating logic, package reference removal, and user message display |
src/Aspire.Cli/Projects/FallbackProjectParser.cs |
Added parsing support for new SDK attribute format with version extraction logic |
Files not reviewed (1)
- src/Aspire.Cli/Resources/UpdateCommandStrings.Designer.cs: Language not supported
| <ItemGroup> | ||
|
|
||
| </ItemGroup> |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The snapshot file shows that the empty <ItemGroup> element is NOT being removed, contradicting the test name and comment which state "RemovesEmptyItemGroupAfterPackageRemoval". The verified XML still contains:
<ItemGroup>
</ItemGroup>This indicates a bug in either:
- The
IsEmptyOrWhitespacemethod that checks if an ItemGroup is empty - The
RemovePackageReferencemethod's logic for removing empty ItemGroups
Looking at the implementation in ProjectUpdater.cs at line 485, it only removes the ItemGroup if it's empty. However, the snapshot suggests the ItemGroup still has whitespace nodes that aren't being properly identified as "empty".
| public async Task UpdateSdkVersionInCsprojAppHostAsync_RemovesEmptyItemGroupAfterPackageRemoval() | ||
| { | ||
| // Arrange - tests that empty ItemGroup is removed after Aspire.Hosting.AppHost removal | ||
| using var workspace = TemporaryWorkspace.Create(outputHelper); | ||
| var projectFile = Path.Combine(workspace.WorkspaceRoot.FullName, "AppHost.csproj"); | ||
| var originalContent = """ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <Sdk Name="Aspire.AppHost.Sdk" Version="9.5.0" /> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net9.0</TargetFramework> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting.AppHost" Version="9.5.0" /> | ||
| </ItemGroup> | ||
| </Project> | ||
| """; | ||
|
|
||
| await File.WriteAllTextAsync(projectFile, originalContent); | ||
|
|
||
| var package = new NuGetPackageCli { Id = "Aspire.AppHost.Sdk", Version = "13.0.2", Source = "nuget.org" }; | ||
|
|
||
| // Act | ||
| await ProjectUpdater.UpdateSdkVersionInCsprojAppHostAsync(new FileInfo(projectFile), package); | ||
|
|
||
| // Assert | ||
| var updatedContent = await File.ReadAllTextAsync(projectFile); | ||
| await Verify(updatedContent, extension: "xml"); | ||
| } |
Copilot
AI
Dec 6, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test is named RemovesEmptyItemGroupAfterPackageRemoval and the comment states "tests that empty ItemGroup is removed", but the actual verified output shows the empty <ItemGroup> is still present (lines 7-9 of the verified XML). Either:
- The test name and comment are incorrect and should reflect that empty ItemGroups are preserved, OR
- There's a bug in the implementation that needs to be fixed
The former seems unlikely given the deliberate naming. This test appears to be failing its intended purpose.
Description
This PR improves the Aspire CLI's handling of the new SDK-style project format and provides better migration support when updating AppHost projects.
Fixes #13000
Fixes #13348
Fixes #13332
Checklist