Skip to content

Fix Doctor suggesting a downgrade on a preview .NET SDK - #229

Merged
Redth merged 1 commit into
mainfrom
redth-fix-preview-sdk-downgrade-warning
Aug 12, 2026
Merged

Redth merged 1 commit into
mainfrom
redth-fix-preview-sdk-downgrade-warning

Conversation

@Redth

@Redth Redth commented Aug 12, 2026

Copy link
Copy Markdown
Owner

Why

When the active .NET SDK is a preview sitting on a higher feature band than the newest published release, Doctor wrongly reported an "update" that is actually a downgrade. For example, with 10.0.400-preview.0.26322.102 installed (band 400, a nightly not yet in the releases feed), Doctor showed:

.NET SDK ⚠️ Update available: 10.0.302

10.0.302 (band 300, stable) is older than the installed preview, so this is a downgrade, not an update. This is what issue #206 reports ("if I am on a .net preview doctor will yell at me").

What changed

The .NET SDK check in DoctorService.RunDoctorAsync picked the "latest available" release for the major with FirstOrDefault(s => s.Major == ...) and compared it to the installed version using string inequality. Any differing string counted as an update, even a lower one.

  • Added an internal helper FindNewerAvailableSdk(available, installed) that returns the newest available SDK for the same major that is semantically newer than the installed one, using the existing SdkVersion.SemanticVersion / NuGetVersion ordering. It returns null when nothing newer exists.
  • The preview branch now keeps the informational Preview SDK (...) status unless a genuinely newer version is available, so a lower published release is never offered as an update.
  • Applied the same strictly-newer guard to the stable branch for symmetry, so a stable SDK ahead of the feed can't be told to downgrade either.
  • The dotnetup managed-channel path is unchanged; it already reports exactly what its tracked channel resolves to.

Tests

Added 5 unit tests in DoctorPreviewSdkTests.cs for the new helper: higher-band preview vs lower published stable (no update), genuinely newer preview (returned), newer stable (returned), already latest (none), and other-major versions ignored. Full MauiSherpa.Core.Tests Doctor suite passes (14/14).

Fixes: #206

When the active SDK is a preview on a higher feature band than the newest published release (e.g. 10.0.400-preview vs stable 10.0.302), Doctor warned 'Update available: 10.0.302' -- a downgrade. The preview/stable branches compared versions by string inequality and took the first available release for the major, ignoring semantic ordering.

Add FindNewerAvailableSdk helper that only returns an available SDK that is semantically newer (via SdkVersion/NuGetVersion ordering) than the installed one, and use it in both branches so lower versions are never offered as updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@Redth
Redth merged commit b4ddc92 into main Aug 12, 2026
1 check passed
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.

If I am on a .net preview doctor will yell at me

1 participant