Allow .NET 10 prerelease versions for single-file apphost scenarios#11599
Allow .NET 10 prerelease versions for single-file apphost scenarios#11599mitchdenny merged 2 commits intomainfrom
Conversation
Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
aspire CLI on a single file apphost (a *.cs file instead of a *.csproj file) it upgrades the SDK requirement from 9.0.300 to 10.0.100. Unfortunately .NET 10.0.100` has not be released yet and we rely on developers setting...|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11599Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11599" |
There was a problem hiding this comment.
Pull Request Overview
This PR modifies the .NET SDK version checking logic in the Aspire CLI to accept .NET 10 prerelease versions when using single-file apphost scenarios, eliminating the need for developers to manually configure overrideMinimumSdkVersion while maintaining strict version checking for other use cases.
- Modified SDK version checking to use a new
MeetsMinimumRequirement()helper method - Added special handling for .NET 10 requirements to accept any version with
Major >= 10 - Preserved existing strict version comparison behavior for all other scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/Aspire.Cli/DotNet/DotNetSdkInstaller.cs |
Added new MeetsMinimumRequirement() method with special .NET 10 handling and updated existing logic to use it |
tests/Aspire.Cli.Tests/DotNetSdkInstallerTests.cs |
Added comprehensive unit tests to verify .NET 10 prerelease acceptance and preservation of strict comparison for other versions |
| var method = typeof(DotNetSdkInstaller).GetMethod("MeetsMinimumRequirement", | ||
| System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static); | ||
| var result = (bool)method!.Invoke(null, new object[] { installedVersion, requiredVersion, requiredVersionString })!; |
There was a problem hiding this comment.
The reflection code for accessing the private method is duplicated across multiple test methods. Consider extracting this into a private helper method to reduce duplication and improve maintainability.
| private static bool MeetsMinimumRequirement(SemVersion installedVersion, SemVersion requiredVersion, string requiredVersionString) | ||
| { | ||
| // Special handling for .NET 10.0.100 requirement - allow any .NET 10.x version | ||
| if (requiredVersionString == MinimumSdkVersionSingleFileAppHost) | ||
| { | ||
| // If we require 10.0.100, accept any version that is >= 10.0.0 |
There was a problem hiding this comment.
The method depends on a magic string comparison with MinimumSdkVersionSingleFileAppHost. Consider adding a parameter or using a more explicit approach to indicate when single-file apphost logic should be applied, making the intent clearer and reducing coupling to specific version strings.
| private static bool MeetsMinimumRequirement(SemVersion installedVersion, SemVersion requiredVersion, string requiredVersionString) | |
| { | |
| // Special handling for .NET 10.0.100 requirement - allow any .NET 10.x version | |
| if (requiredVersionString == MinimumSdkVersionSingleFileAppHost) | |
| { | |
| // If we require 10.0.100, accept any version that is >= 10.0.0 | |
| private static bool MeetsMinimumRequirement(SemVersion installedVersion, SemVersion requiredVersion, bool isSingleFileAppHostRequired) | |
| { | |
| // Special handling for .NET 10.x requirement - allow any .NET 10.x version | |
| if (isSingleFileAppHostRequired) | |
| { | |
| // If single-file apphost is required, accept any version that is >= 10.0.0 |
|
/backport to release/9.5 |
|
Started backporting to release/9.5: https://github.com/dotnet/aspire/actions/runs/17962447808 |
Problem
When using the Aspire CLI with single-file apphosts (*.cs files), the SDK requirement is elevated from
9.0.302to10.0.100. However, since .NET 10.0.100 RTM has not been released yet, developers must manually configureoverrideMinimumSdkVersionto use available .NET 10 prerelease versions, creating unnecessary friction.Solution
This change modifies the SDK version checking logic to accept any .NET 10.x version (including prereleases) when the single-file apphost feature is enabled, while maintaining strict version checking for all other scenarios.
Technical Changes
DotNetSdkInstaller.CheckAsync()to use a newMeetsMinimumRequirement()helper methodMajor >= 10SemVersion.ComparePrecedenceExamples
Before this change:
After this change:
Testing
Added comprehensive unit tests verifying:
Impact
This eliminates the need for developers to manually configure
overrideMinimumSdkVersionwhen using .NET 10 prereleases with single-file apphosts, reducing friction while maintaining version safety for all other use cases.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.