Skip to content

Commit 5a038a8

Browse files
authored
Use Ubuntu 24.04 Noble Numbat images by default starting in 8.0.300 (#39614)
1 parent c9738e9 commit 5a038a8

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

src/Containers/Microsoft.NET.Build.Containers/Tasks/ComputeDotnetBaseImageAndTag.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public sealed class ComputeDotnetBaseImageAndTag : Microsoft.Build.Utilities.Tas
4040
public ITaskItem[] FrameworkReferences { get; set; }
4141

4242
/// <summary>
43-
/// If this is set to linux-ARCH then we use jammy-chiseled for the AOT/Extra/etc decisions.
43+
/// If this is set to linux-ARCH then we use noble-chiseled for the AOT/Extra/etc decisions.
4444
/// If this is set to linux-musl-ARCH then we need to use `alpine` for all containers, and tag on `aot` or `extra` as necessary.
4545
/// </summary>
4646
[Required]
@@ -65,7 +65,7 @@ public sealed class ComputeDotnetBaseImageAndTag : Microsoft.Build.Utilities.Tas
6565

6666
/// <summary>
6767
/// If set, this expresses a preference for a variant of the container image that we infer for a project.
68-
/// e.g. 'alpine', or 'jammy-chiseled'
68+
/// e.g. 'alpine', or 'noble-chiseled'
6969
/// </summary>
7070
public string ContainerFamily { get; set; }
7171

@@ -105,10 +105,23 @@ public override bool Execute()
105105
return !Log.HasLoggedErrors;
106106
}
107107

108+
private string UbuntuCodenameForSDKVersion(SemanticVersion version)
109+
{
110+
if (version >= SemanticVersion.Parse("8.0.300"))
111+
{
112+
return "noble";
113+
}
114+
else
115+
{
116+
return "jammy";
117+
}
118+
}
119+
108120
private bool ComputeRepositoryAndTag([NotNullWhen(true)] out string? repository, [NotNullWhen(true)] out string? tag)
109121
{
110122
if (ComputeVersionPart() is (string baseVersionPart, SemanticVersion parsedVersion, bool versionAllowsUsingAOTAndExtrasImages))
111123
{
124+
var defaultUbuntuVersion = UbuntuCodenameForSDKVersion(parsedVersion);
112125
Log.LogMessage("Computed base version tag of {0} from TFM {1} and SDK {2}", baseVersionPart, TargetFrameworkVersion, SdkVersion);
113126
if (baseVersionPart is null)
114127
{
@@ -139,7 +152,7 @@ private bool ComputeRepositoryAndTag([NotNullWhen(true)] out string? repository,
139152
// in question, and the app is globalized, we can help and add -extra so the app will actually run
140153

141154
if (
142-
(!IsMuslRid && ContainerFamily == "jammy-chiseled") // default for linux RID
155+
(!IsMuslRid && ContainerFamily.EndsWith("-chiseled")) // default for linux RID
143156
&& !UsesInvariantGlobalization
144157
&& versionAllowsUsingAOTAndExtrasImages
145158
// the extras only became available on the stable tags of the FirstVersionWithNewTaggingScheme
@@ -170,8 +183,8 @@ private bool ComputeRepositoryAndTag([NotNullWhen(true)] out string? repository,
170183
{
171184
true => "-alpine",
172185
// default to chiseled for AOT, non-musl Apps
173-
false when IsAotPublished || IsTrimmed => "-jammy-chiseled", // TODO: should we default here to jammy-chiseled for non-musl RIDs?
174-
// default to jammy for non-AOT, non-musl Apps
186+
false when IsAotPublished || IsTrimmed => $"-{defaultUbuntuVersion}-chiseled", // TODO: should we default here to noble-chiseled for non-musl RIDs?
187+
// default to noble for non-AOT, non-musl Apps
175188
false => ""
176189
};
177190

src/Tests/Microsoft.NET.Build.Containers.IntegrationTests/TargetsTests.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ public void WindowsUsersGetLinuxContainers(string sdkPortableRid, string expecte
323323
[InlineData("8.0.100-preview.2", "v8.0", "jammy-chiseled", "8.0.0-preview.2-jammy-chiseled")]
324324
[InlineData("8.0.100-rc.2", "v8.0", "jammy-chiseled", "8.0.0-rc.2-jammy-chiseled")]
325325
[InlineData("8.0.100", "v8.0", "jammy-chiseled", "8.0-jammy-chiseled-extra")]
326+
[InlineData("8.0.200", "v8.0", "jammy-chiseled", "8.0-jammy-chiseled-extra")]
327+
[InlineData("8.0.300", "v8.0", "noble-chiseled", "8.0-noble-chiseled-extra")]
328+
[InlineData("8.0.300", "v8.0", "jammy-chiseled", "8.0-jammy-chiseled-extra")]
326329
[Theory]
327330
public void CanTakeContainerBaseFamilyIntoAccount(string sdkVersion, string tfmMajMin, string containerFamily, string expectedTag)
328331
{
@@ -383,13 +386,13 @@ public void AOTAppsGetAOTImages(string rid, string expectedImage)
383386
}
384387

385388
[InlineData("linux-musl-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-extra")]
386-
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra")]
389+
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra")]
387390
[Theory]
388391
public void AOTAppsWithCulturesGetExtraImages(string rid, string expectedImage)
389392
{
390393
var (project, logger, d) = ProjectInitializer.InitProject(new()
391394
{
392-
["NetCoreSdkVersion"] = "8.0.100",
395+
["NetCoreSdkVersion"] = "8.0.300",
393396
["TargetFrameworkVersion"] = "v8.0",
394397
[KnownStrings.Properties.ContainerRuntimeIdentifier] = rid,
395398
[KnownStrings.Properties.PublishSelfContained] = true.ToString(),
@@ -404,13 +407,13 @@ public void AOTAppsWithCulturesGetExtraImages(string rid, string expectedImage)
404407
}
405408

406409
[InlineData("linux-musl-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-extra")]
407-
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra")]
410+
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra")]
408411
[Theory]
409412
public void TrimmedAppsWithCulturesGetExtraImages(string rid, string expectedImage)
410413
{
411414
var (project, logger, d) = ProjectInitializer.InitProject(new()
412415
{
413-
["NetCoreSdkVersion"] = "8.0.100",
416+
["NetCoreSdkVersion"] = "8.0.300",
414417
["TargetFrameworkVersion"] = "v8.0",
415418
[KnownStrings.Properties.ContainerRuntimeIdentifier] = rid,
416419
[KnownStrings.Properties.PublishSelfContained] = true.ToString(),
@@ -425,13 +428,13 @@ public void TrimmedAppsWithCulturesGetExtraImages(string rid, string expectedIma
425428
}
426429

427430
[InlineData("linux-musl-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine")]
428-
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled")]
431+
[InlineData("linux-x64", "mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled")]
429432
[Theory]
430433
public void TrimmedAppsWithoutCulturesGetbaseImages(string rid, string expectedImage)
431434
{
432435
var (project, logger, d) = ProjectInitializer.InitProject(new()
433436
{
434-
["NetCoreSdkVersion"] = "8.0.100",
437+
["NetCoreSdkVersion"] = "8.0.300",
435438
["TargetFrameworkVersion"] = "v8.0",
436439
[KnownStrings.Properties.ContainerRuntimeIdentifier] = rid,
437440
[KnownStrings.Properties.PublishSelfContained] = true.ToString(),
@@ -450,16 +453,16 @@ public void TrimmedAppsWithoutCulturesGetbaseImages(string rid, string expectedI
450453
[InlineData(false, true, "linux-musl-x64", true, "mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-alpine-aot")]
451454
[InlineData(false, true, "linux-musl-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine-extra")]
452455

453-
[InlineData(true, false, "linux-x64", true, "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled")]
454-
[InlineData(true, false, "linux-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra")]
455-
[InlineData(false, true, "linux-x64", true, "mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-jammy-chiseled-aot")]
456-
[InlineData(false, true, "linux-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-jammy-chiseled-extra")]
456+
[InlineData(true, false, "linux-x64", true, "mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled")]
457+
[InlineData(true, false, "linux-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra")]
458+
[InlineData(false, true, "linux-x64", true, "mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-noble-chiseled-aot")]
459+
[InlineData(false, true, "linux-x64", false, "mcr.microsoft.com/dotnet/runtime-deps:8.0-noble-chiseled-extra")]
457460
[Theory]
458461
public void TheBigMatrixOfTrimmingInference(bool trimmed, bool aot, string rid, bool invariant, string expectedImage)
459462
{
460463
var (project, logger, d) = ProjectInitializer.InitProject(new()
461464
{
462-
["NetCoreSdkVersion"] = "8.0.100",
465+
["NetCoreSdkVersion"] = "8.0.300",
463466
["TargetFrameworkVersion"] = "v8.0",
464467
[KnownStrings.Properties.ContainerRuntimeIdentifier] = rid,
465468
[KnownStrings.Properties.PublishSelfContained] = true.ToString(),

0 commit comments

Comments
 (0)