Skip to content

Allow .NET 10 prerelease versions for single-file apphost scenarios#11599

Merged
mitchdenny merged 2 commits intomainfrom
copilot/fix-f3dc53f3-cd48-4592-a593-135a8e66c4fa
Sep 24, 2025
Merged

Allow .NET 10 prerelease versions for single-file apphost scenarios#11599
mitchdenny merged 2 commits intomainfrom
copilot/fix-f3dc53f3-cd48-4592-a593-135a8e66c4fa

Conversation

Copy link
Contributor

Copilot AI commented Sep 23, 2025

Problem

When using the Aspire CLI with single-file apphosts (*.cs files), the SDK requirement is elevated from 9.0.302 to 10.0.100. However, since .NET 10.0.100 RTM has not been released yet, developers must manually configure overrideMinimumSdkVersion to 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

  • Modified DotNetSdkInstaller.CheckAsync() to use a new MeetsMinimumRequirement() helper method
  • Added special handling for .NET 10 requirements that accepts any version with Major >= 10
  • Preserved existing behavior for all other version requirements using strict SemVersion.ComparePrecedence

Examples

Before this change:

SDK 10.0.100-rc.1.25420.111 detected
Requirement: 10.0.100
Result: ❌ FAIL (prerelease < RTM)

After this change:

SDK 10.0.100-rc.1.25420.111 detected  
Requirement: 10.0.100
Result: ✅ PASS (10.x prerelease accepted)

Testing

Added comprehensive unit tests verifying:

  • .NET 10 prereleases are accepted for single-file apphost requirements
  • .NET 9 versions are still rejected for single-file apphost requirements
  • Other version requirements continue using strict comparison
  • Multiple .NET 10 prerelease formats work correctly

Impact

This eliminates the need for developers to manually configure overrideMinimumSdkVersion when 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.

Co-authored-by: mitchdenny <513398+mitchdenny@users.noreply.github.com>
Copilot AI changed the title [WIP] Currently when using the 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... Allow .NET 10 prerelease versions for single-file apphost scenarios Sep 23, 2025
Copilot AI requested a review from mitchdenny September 23, 2025 08:02
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11599

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11599"

@mitchdenny mitchdenny marked this pull request as ready for review September 23, 2025 22:46
Copilot AI review requested due to automatic review settings September 23, 2025 22:46
Copy link
Contributor

Copilot AI left a 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 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

Comment on lines +251 to +253
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 })!;
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +164 to +169
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
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
@mitchdenny mitchdenny added this to the 9.5 milestone Sep 23, 2025
@mitchdenny mitchdenny merged commit a77692e into main Sep 24, 2025
311 checks passed
@mitchdenny mitchdenny deleted the copilot/fix-f3dc53f3-cd48-4592-a593-135a8e66c4fa branch September 24, 2025 00:17
@dotnet-policy-service dotnet-policy-service bot modified the milestones: 9.5, 9.6 Sep 24, 2025
@mitchdenny
Copy link
Member

/backport to release/9.5

@github-actions
Copy link
Contributor

Started backporting to release/9.5: https://github.com/dotnet/aspire/actions/runs/17962447808

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants