Skip to content

Commit a947984

Browse files
committed
Add .NET 9 container build image support
1 parent e93f6e9 commit a947984

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Projects": [
3+
{
4+
"Name": "Amazon.Lambda.Tools",
5+
"Type": "Minor",
6+
"ChangelogMessages": [
7+
"Add container build support for .NET 9. This allows Native AOT .NET 9 Lambda function builds."
8+
]
9+
}
10+
]
11+
}

src/Amazon.Lambda.Tools/LambdaUtilities.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace Amazon.Lambda.Tools
2626
{
2727
public static class TargetFrameworkMonikers
2828
{
29+
public const string net90 = "net9.0";
2930
public const string net80 = "net8.0";
3031
public const string net70 = "net7.0";
3132
public const string net60 = "net6.0";
@@ -46,7 +47,8 @@ public static class TargetFrameworkMonikers
4647
net50,
4748
net60,
4849
net70,
49-
net80
50+
net80,
51+
net90
5052
};
5153
}
5254

@@ -56,7 +58,7 @@ public static class LambdaUtilities
5658

5759
public static readonly IReadOnlyDictionary<string, string> _lambdaRuntimeToDotnetFramework = new Dictionary<string, string>()
5860
{
59-
{"dotnet8", TargetFrameworkMonikers.net80}, // Use the string version since the SDK hasn't been updated yet.
61+
{Amazon.Lambda.Runtime.Dotnet8.Value, TargetFrameworkMonikers.net80},
6062
{Amazon.Lambda.Runtime.Dotnet6.Value, TargetFrameworkMonikers.net60},
6163
{Amazon.Lambda.Runtime.Dotnetcore31.Value, TargetFrameworkMonikers.netcoreapp31},
6264
{Amazon.Lambda.Runtime.Dotnetcore21.Value, TargetFrameworkMonikers.netcoreapp21},
@@ -121,6 +123,8 @@ public static string GetDefaultBuildImage(string targetFramework, string archite
121123

122124
switch (targetFramework?.ToLower())
123125
{
126+
case TargetFrameworkMonikers.net90:
127+
return $"public.ecr.aws/sam/build-dotnet9:latest-{architecture}";
124128
case TargetFrameworkMonikers.net80:
125129
return $"public.ecr.aws/sam/build-dotnet8:latest-{architecture}";
126130
case TargetFrameworkMonikers.net70:

test/Amazon.Lambda.Tools.Test/UtilitiesTests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ public void TestSavingDockerfileInDefaults(string dockerfilePath, string project
175175
[InlineData("net7.0", LambdaConstants.ARCHITECTURE_X86_64, "public.ecr.aws/sam/build-dotnet7:latest-x86_64")]
176176
[InlineData("net7.0", " ", "public.ecr.aws/sam/build-dotnet7:latest-x86_64")]
177177
[InlineData("net7.0", LambdaConstants.ARCHITECTURE_ARM64, "public.ecr.aws/sam/build-dotnet7:latest-arm64")]
178+
[InlineData("net8.0", LambdaConstants.ARCHITECTURE_ARM64, "public.ecr.aws/sam/build-dotnet8:latest-arm64")]
179+
[InlineData("net8.0", LambdaConstants.ARCHITECTURE_X86_64, "public.ecr.aws/sam/build-dotnet8:latest-x86_64")]
180+
[InlineData("net9.0", LambdaConstants.ARCHITECTURE_ARM64, "public.ecr.aws/sam/build-dotnet9:latest-arm64")]
181+
[InlineData("net9.0", LambdaConstants.ARCHITECTURE_X86_64, "public.ecr.aws/sam/build-dotnet9:latest-x86_64")]
178182
[InlineData(null, LambdaConstants.ARCHITECTURE_X86_64, "throws")]
179183
[InlineData(null, LambdaConstants.ARCHITECTURE_ARM64, "throws")]
180184
public void GetDefaultBuildImage(string targetFramework, string architecture, string expectedValue)

0 commit comments

Comments
 (0)