-
Notifications
You must be signed in to change notification settings - Fork 648
Add CLI version update notifications to Aspire CLI #9992
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
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
{ | ||
try | ||
{ | ||
await nuGetPackageCache.GetCliPackagesAsync( |
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.
@copilot consolidate this code into the background task above, there is no need to fire off two tasks here. They can both be done concurrently and a Task.WhenAny can be used to merge them back in. Move each prefetch operation into its own method so that a log message can be customized for each one.
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.
I've consolidated the code as requested. The two separate Task.Run operations are now combined into a single background task using Task.WhenAll, and I've extracted PrefetchTemplatePackagesAsync() and PrefetchCliPackagesAsync() methods with customized log messages for each operation. The CLI packages prefetch method now includes "for update notifications" in its log message to distinguish it from the template prefetch. Commit: 7a25bf8
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Is this going to show up when you don't acquire it as a .NET tool? |
src/Aspire.Cli/Program.cs
Outdated
@@ -174,11 +175,30 @@ public static async Task<int> Main(string[] args) | |||
using var activity = telemetry.ActivitySource.StartActivity(); | |||
var exitCode = await config.InvokeAsync(args); | |||
|
|||
// Check for CLI updates after command execution |
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.
Why after?
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.
I've moved the update check to run before command execution instead of after. This provides better user experience by showing notifications upfront rather than after the user's intended operation completes. The check still skips help commands to avoid notification spam. Commit: aa134f2
…tool and move to before command execution Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
I've added detection logic to only show update notifications when the CLI is running as a .NET global tool. The service now checks if the process path or base directory contains ".dotnet/tools" (the typical location for global tools) and skips the notification if it's not detected. This prevents misleading update instructions for users running the CLI from source builds or other non-tool installations. Commit: aa134f2 |
Summary
Implements automatic update notifications for the Aspire CLI that notify users when newer versions are available on NuGet, following the specified notification rules for stable and prerelease versions.
Changes
Core Implementation
INuGetPackageCache
withGetCliPackagesAsync()
method to query Aspire.Cli packages with 1-hour cache expirationNuGetPackagePrefetcher
to prefetch CLI versions in background alongside existing template prefetchCliUpdateNotificationService
that implements version comparison logic and displays update notificationsProgram.Main
to check for updates after successful command executionNotification Rules
The implementation follows the exact rules specified in the issue:
Example Output
Key Features
SemVersion.PrecedenceComparer
for proper version comparisonFiles Changed
src/Aspire.Cli/NuGet/NuGetPackageCache.cs
- Added CLI package query methodsrc/Aspire.Cli/NuGet/NuGetPackagePrefetcher.cs
- Extended to prefetch CLI versionssrc/Aspire.Cli/Utils/CliUpdateNotificationService.cs
- New service for update logicsrc/Aspire.Cli/Program.cs
- Integration into main CLI flowtests/Aspire.Cli.Tests/Utils/CliUpdateNotificationServiceTests.cs
- Unit testsTesting
Added unit tests that verify:
Implementation Notes
The feature is now ready for users to receive automatic notifications about available CLI updates during normal usage.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.