Skip to content

Fix -extra container variant check to support .NET 9+#52161

Merged
baronfel merged 5 commits intomainfrom
copilot/fix-container-targets-comparison
Jan 21, 2026
Merged

Fix -extra container variant check to support .NET 9+#52161
baronfel merged 5 commits intomainfrom
copilot/fix-container-targets-comparison

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

The -extra base image variant was only applied for .NET 8 due to an equality check instead of a range check, breaking support for .NET 9 and later.

Changes

  • Fixed version comparison in ComputeDotnetBaseImageAndTag.cs:

    • Changed parsedVersion.Major == FirstVersionWithNewTaggingScheme to parsedVersion.Major >= FirstVersionWithNewTaggingScheme
    • Ensures .NET 8+ applications using chiseled containers without InvariantGlobalization correctly receive the -extra variant containing ICU and tzdata
  • Added test coverage for .NET 8.0, 9.0, and 10.0:

    • FDDConsoleAppWithCulturesAndOptingIntoChiseledGetsExtrasForNet9AndLater
    • FDDAspNetAppWithCulturesAndOptingIntoChiseledGetsExtrasForNet9AndLater
    • Verify console and ASP.NET apps get correct -extra tags for current and future SDK versions

Context

The -extra variants became available starting with .NET 8's new tagging scheme. The original implementation incorrectly hard-coded the version check to exactly 8, preventing the logic from working with newer SDK versions.

// Before: Only .NET 8
&& (!parsedVersion.IsPrerelease && parsedVersion.Major == FirstVersionWithNewTaggingScheme)

// After: .NET 8 and all future versions
&& (!parsedVersion.IsPrerelease && parsedVersion.Major >= FirstVersionWithNewTaggingScheme)
Original prompt

This section details on the original issue you should resolve

<issue_title>How to use "-extra" base image via InvariantGlobalization?</issue_title>
<issue_description>This is a bug in the containers targets - when we check if we can add the -extra variant to the users' ContainerFamily, we check if the target runtime == 8, not >= 8 (when the -extras first became available).

We should fix this comparison and add tests to the existing targets test to verify the expected behavior.

Discussed in #52158

Originally posted by mu88 December 15, 2025
Hi @baronfel,

When using the .NET SDK Container Building Tools and setting the MSBuild property InvariantGlobalization to false, the base image with the -extra suffix is not used:
image

Based on the log statement Using user-provided ContainerFamily, I was able to find this spot in the code.
However, I'm wondering about why I'm not ending up here 🤔

Do you have a hint for me?

Here's my repro workflow:

  1. dotnet new webapi
  2. dotnet publish /t:PublishContainer /p:InvariantGlobalization=false /p:ContainerRuntimeIdentifier=linux-x64 /p:ContainerFamily=noble-chiseled /bl
  3. Open the MSBuild log with MSBuild Structured Log Viewer
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… .NET 9/10

Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
@baronfel baronfel requested a review from a team December 15, 2025 15:55
@baronfel baronfel marked this pull request as ready for review December 15, 2025 15:55
Copilot AI review requested due to automatic review settings December 15, 2025 15:55
Copilot AI and others added 2 commits December 15, 2025 16:01
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix comparison for -extra base image in ContainerFamily Fix -extra container variant check to support .NET 9+ Dec 15, 2025
Copilot AI requested a review from baronfel December 15, 2025 16:07
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@baronfel baronfel enabled auto-merge (squash) December 15, 2025 17:50
@baronfel baronfel added the Area-Containers Related to dotnet SDK containers functionality label Jan 20, 2026
Copy link
Member

@mthalman mthalman left a comment

Choose a reason for hiding this comment

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

@copilot - Address my review comments.

Comment on lines +617 to +618
[InlineData("9.0.100", "v9.0", "noble-chiseled", "mcr.microsoft.com/dotnet/runtime:9.0-noble-chiseled-extra")]
[InlineData("10.0.100", "v10.0", "noble-chiseled", "mcr.microsoft.com/dotnet/runtime:10.0-noble-chiseled-extra")]
Copy link
Member

Choose a reason for hiding this comment

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

Might as well cover the 8.0 case here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added .NET 8.0 test case in commit 2397fde.

Comment on lines +637 to +638
[InlineData("9.0.100", "v9.0", "noble-chiseled", "mcr.microsoft.com/dotnet/aspnet:9.0-noble-chiseled-extra")]
[InlineData("10.0.100", "v10.0", "noble-chiseled", "mcr.microsoft.com/dotnet/aspnet:10.0-noble-chiseled-extra")]
Copy link
Member

Choose a reason for hiding this comment

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

Might as well cover the 8.0 case here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added .NET 8.0 test case in commit 2397fde.

Co-authored-by: mthalman <15789599+mthalman@users.noreply.github.com>
auto-merge was automatically disabled January 21, 2026 00:52

Head branch was pushed to by a user without write access

Copilot AI requested a review from mthalman January 21, 2026 00:53
@baronfel baronfel merged commit 605daa8 into main Jan 21, 2026
26 checks passed
@baronfel baronfel deleted the copilot/fix-container-targets-comparison branch January 21, 2026 04:09
@baronfel
Copy link
Member

/backport to release/10.0.1xx

@baronfel
Copy link
Member

/backport to release/10.0.2xx

@github-actions
Copy link
Contributor

Started backporting to release/10.0.1xx (link to workflow run)

@github-actions
Copy link
Contributor

Started backporting to release/10.0.2xx (link to workflow run)

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

Labels

Area-Containers Related to dotnet SDK containers functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to use "-extra" base image via InvariantGlobalization?

4 participants