Skip to content

Commit d6eb809

Browse files
authored
Switch default container build from mcr.microsoft.com/dotnet/sdk:10.0-aot to public.ecr.aws/sam/build-dotnet10:latest (#429)
1 parent 3bf819a commit d6eb809

File tree

9 files changed

+42
-19
lines changed

9 files changed

+42
-19
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": "Patch",
6+
"ChangelogMessages": [
7+
"Switch default container build from mcr.microsoft.com/dotnet/sdk:10.0-aot to public.ecr.aws/sam/build-dotnet10:latest"
8+
]
9+
}
10+
]
11+
}

src/Amazon.Lambda.Tools/LambdaUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public static string GetDefaultBuildImage(string targetFramework, string archite
165165
switch (targetFramework?.ToLower())
166166
{
167167
case TargetFrameworkMonikers.net10_0:
168-
return $"mcr.microsoft.com/dotnet/sdk:10.0-aot";
168+
return $"public.ecr.aws/sam/build-dotnet10:latest-{architecture}";
169169
case TargetFrameworkMonikers.net90:
170170
return $"public.ecr.aws/sam/build-dotnet9:latest-{architecture}";
171171
case TargetFrameworkMonikers.net80:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ public async Task RunDeploymentNativeAot(bool multipleProjects, bool customMount
143143
command.MemorySize = 512;
144144
command.Role = await TestHelper.GetTestRoleArnAsync();
145145
command.Configuration = "Release";
146-
command.TargetFramework = "net7.0";
147-
command.Runtime = "provided.al2";
146+
command.TargetFramework = "net10.0";
147+
command.Runtime = "provided.al2023";
148148
command.DisableInteractive = true;
149149
if (customMountLocation)
150150
{
@@ -175,7 +175,7 @@ public async Task RunDeploymentNativeAot(bool multipleProjects, bool customMount
175175
};
176176
GetFunctionResponse getFunctionResponse = await command.LambdaClient.GetFunctionAsync(getFunctionRequest);
177177
var codeSize = getFunctionResponse.Configuration.CodeSize;
178-
Assert.True(codeSize < 10000000, $"Code size is {codeSize}, which is larger than expected 10000000 bytes (10MB), check that trimming and stripping worked as expected.");
178+
Assert.True(codeSize < 20000000, $"Code size is {codeSize}, which is larger than expected 10000000 bytes (10MB), check that trimming and stripping worked as expected.");
179179
}
180180
finally
181181
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ public void TestSavingDockerfileInDefaults(string dockerfilePath, string project
179179
[InlineData("net8.0", LambdaConstants.ARCHITECTURE_X86_64, "public.ecr.aws/sam/build-dotnet8:latest-x86_64")]
180180
[InlineData("net9.0", LambdaConstants.ARCHITECTURE_ARM64, "public.ecr.aws/sam/build-dotnet9:latest-arm64")]
181181
[InlineData("net9.0", LambdaConstants.ARCHITECTURE_X86_64, "public.ecr.aws/sam/build-dotnet9:latest-x86_64")]
182-
[InlineData("net10.0", LambdaConstants.ARCHITECTURE_ARM64, "mcr.microsoft.com/dotnet/sdk:10.0-aot")]
183-
[InlineData("net10.0", LambdaConstants.ARCHITECTURE_X86_64, "mcr.microsoft.com/dotnet/sdk:10.0-aot")]
182+
[InlineData("net10.0", LambdaConstants.ARCHITECTURE_ARM64, "public.ecr.aws/sam/build-dotnet10:latest-arm64")]
183+
[InlineData("net10.0", LambdaConstants.ARCHITECTURE_X86_64, "public.ecr.aws/sam/build-dotnet10:latest-x86_64")]
184184
[InlineData(null, LambdaConstants.ARCHITECTURE_X86_64, "throws")]
185185
[InlineData(null, LambdaConstants.ARCHITECTURE_ARM64, "throws")]
186186
public void GetDefaultBuildImage(string targetFramework, string architecture, string expectedValue)

testapps/TestNativeAotMultipleProjects/EntryPoint/EntryPoint.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<AWSProjectType>Lambda</AWSProjectType>
@@ -14,14 +14,14 @@
1414
When publishing Lambda functions for ARM64 to the provided.al2 runtime a newer version of libicu needs to be included
1515
in the deployment bundle because .NET requires a newer version of libicu then is preinstalled with Amazon Linux 2.
1616
-->
17-
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">
17+
<ItemGroup>
1818
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
1919
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
2020
</ItemGroup>
2121
<ItemGroup>
22-
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.2" />
23-
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
24-
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />
22+
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.14.1" />
23+
<PackageReference Include="Amazon.Lambda.Core" Version="2.8.0" />
24+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.5" />
2525
</ItemGroup>
2626
<ItemGroup>
2727
<ProjectReference Include="..\Library1\Library1.csproj" />

testapps/TestNativeAotMultipleProjects/EntryPoint/Function.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Amazon.Lambda.Core;
22
using Amazon.Lambda.RuntimeSupport;
33
using Amazon.Lambda.Serialization.SystemTextJson;
4+
using System.Text.Json.Serialization;
45

56
namespace NativeAotTest;
67

@@ -13,7 +14,7 @@ public class Function
1314
private static async Task Main(string[] args)
1415
{
1516
Func<string, ILambdaContext, string> handler = FunctionHandler;
16-
await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
17+
await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext>())
1718
.Build()
1819
.RunAsync();
1920
}
@@ -33,4 +34,9 @@ public static string FunctionHandler(string input, ILambdaContext context)
3334
var class1 = new Class1 { Name = $"MyTest: {input}" };
3435
return class1.Name.ToUpper();
3536
}
37+
}
38+
39+
[JsonSerializable(typeof(string))]
40+
public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext
41+
{
3642
}

testapps/TestNativeAotMultipleProjects/Library1/Library1.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>

testapps/TestNativeAotSingleProject/EntryPoint.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<AWSProjectType>Lambda</AWSProjectType>
@@ -15,13 +15,13 @@
1515
When publishing Lambda functions for ARM64 to the provided.al2 runtime a newer version of libicu needs to be included
1616
in the deployment bundle because .NET requires a newer version of libicu then is preinstalled with Amazon Linux 2.
1717
-->
18-
<ItemGroup Condition="'$(RuntimeIdentifier)' == 'linux-arm64'">
18+
<ItemGroup>
1919
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" />
2020
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
2121
</ItemGroup>
2222
<ItemGroup>
23-
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.8.2" />
24-
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
25-
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />
23+
<PackageReference Include="Amazon.Lambda.RuntimeSupport" Version="1.14.1" />
24+
<PackageReference Include="Amazon.Lambda.Core" Version="2.8.0" />
25+
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.4.5" />
2626
</ItemGroup>
2727
</Project>

testapps/TestNativeAotSingleProject/Function.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Amazon.Lambda.Core;
22
using Amazon.Lambda.RuntimeSupport;
33
using Amazon.Lambda.Serialization.SystemTextJson;
4+
using System.Text.Json.Serialization;
45

56
namespace NativeAotTest;
67

@@ -13,7 +14,7 @@ public class Function
1314
private static async Task Main(string[] args)
1415
{
1516
Func<string, ILambdaContext, string> handler = FunctionHandler;
16-
await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
17+
await LambdaBootstrapBuilder.Create(handler, new SourceGeneratorLambdaJsonSerializer<LambdaFunctionJsonSerializerContext>())
1718
.Build()
1819
.RunAsync();
1920
}
@@ -32,4 +33,9 @@ public static string FunctionHandler(string input, ILambdaContext context)
3233
{
3334
return input.ToUpper();
3435
}
36+
}
37+
38+
[JsonSerializable(typeof(string))]
39+
public partial class LambdaFunctionJsonSerializerContext : JsonSerializerContext
40+
{
3541
}

0 commit comments

Comments
 (0)