diff --git a/aws_lambda_builders/validator.py b/aws_lambda_builders/validator.py
index 1da97275a..94e4d331b 100644
--- a/aws_lambda_builders/validator.py
+++ b/aws_lambda_builders/validator.py
@@ -25,6 +25,7 @@
"java21": [ARM64, X86_64],
"go1.x": [ARM64, X86_64],
"dotnet6": [ARM64, X86_64],
+ "dotnet8": [ARM64, X86_64],
"provided": [ARM64, X86_64],
}
diff --git a/tests/functional/test_actions.py b/tests/functional/test_actions.py
index 9909bcffe..d26647e2e 100644
--- a/tests/functional/test_actions.py
+++ b/tests/functional/test_actions.py
@@ -30,7 +30,7 @@ def test_copy_dependencies_action(self, source_folder):
copy_dependencies_action = CopyDependenciesAction(empty_source, test_folder, target)
copy_dependencies_action.execute()
- self.assertEqual(os.listdir(test_folder), os.listdir(target))
+ self.assertEqual(set(os.listdir(test_folder)), set(os.listdir(target)))
def test_must_maintain_symlinks_if_enabled(self):
with tempfile.TemporaryDirectory() as tmpdir:
@@ -116,4 +116,4 @@ def test_move_dependencies_action(self, source_folder):
move_dependencies_action = MoveDependenciesAction(empty_source, test_source, target)
move_dependencies_action.execute()
- self.assertEqual(os.listdir(test_folder), os.listdir(target))
+ self.assertEqual(set(os.listdir(test_folder)), set(os.listdir(target)))
diff --git a/tests/integration/workflows/dotnet_clipackage/test_dotnet.py b/tests/integration/workflows/dotnet_clipackage/test_dotnet.py
index 187a9c7ab..95743d112 100644
--- a/tests/integration/workflows/dotnet_clipackage/test_dotnet.py
+++ b/tests/integration/workflows/dotnet_clipackage/test_dotnet.py
@@ -2,6 +2,7 @@
import shutil
import tempfile
import json
+from parameterized import parameterized
try:
import pathlib
@@ -25,13 +26,12 @@ def setUp(self):
self.artifacts_dir = tempfile.mkdtemp()
self.scratch_dir = tempfile.mkdtemp()
self.builder = LambdaBuilder(language="dotnet", dependency_manager="cli-package", application_framework=None)
- self.runtime = "dotnet6"
def tearDown(self):
shutil.rmtree(self.artifacts_dir)
shutil.rmtree(self.scratch_dir)
- def verify_architecture(self, deps_file_name, expected_architecture, version=None):
+ def verify_architecture(self, deps_file_name, expected_architecture, version):
deps_file = pathlib.Path(self.artifacts_dir, deps_file_name)
if not deps_file.exists():
@@ -39,7 +39,6 @@ def verify_architecture(self, deps_file_name, expected_architecture, version=Non
with open(str(deps_file)) as f:
deps_json = json.loads(f.read())
- version = version or self.runtime[-3:]
target_name = ".NETCoreApp,Version=v{}/{}".format(version, expected_architecture)
target = deps_json.get("runtimeTarget").get("name")
@@ -50,19 +49,24 @@ def verify_execute_permissions(self, entrypoint_file_name):
self.assertTrue(os.access(entrypoint_file_path, os.X_OK))
-class TestDotnet6(TestDotnetBase):
+class TestDotnet(TestDotnetBase):
"""
- Tests for dotnet 6
+ Tests for dotnet
"""
def setUp(self):
- super(TestDotnet6, self).setUp()
- self.runtime = "dotnet6"
+ super(TestDotnet, self).setUp()
- def test_with_defaults_file(self):
- source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")
+ @parameterized.expand(
+ [
+ ("dotnet6", "6.0", "WithDefaultsFile6"),
+ ("dotnet8", "8.0", "WithDefaultsFile8"),
+ ]
+ )
+ def test_with_defaults_file(self, runtime, version, test_project):
+ source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
- self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime)
+ self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime)
expected_files = {
"Amazon.Lambda.Core.dll",
@@ -77,14 +81,18 @@ def test_with_defaults_file(self):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
- self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version="6.0")
+ self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version)
- def test_with_defaults_file_x86(self):
- source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")
+ @parameterized.expand(
+ [
+ ("dotnet6", "6.0", "WithDefaultsFile6"),
+ ("dotnet8", "8.0", "WithDefaultsFile8"),
+ ]
+ )
+ def test_with_defaults_file_x86(self, runtime, version, test_project):
+ source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
- self.builder.build(
- source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=X86_64
- )
+ self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime, architecture=X86_64)
expected_files = {
"Amazon.Lambda.Core.dll",
@@ -99,14 +107,18 @@ def test_with_defaults_file_x86(self):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
- self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version="6.0")
+ self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version)
- def test_with_defaults_file_arm64(self):
- source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")
+ @parameterized.expand(
+ [
+ ("dotnet6", "6.0", "WithDefaultsFile6"),
+ ("dotnet8", "8.0", "WithDefaultsFile8"),
+ ]
+ )
+ def test_with_defaults_file_arm64(self, runtime, version, test_project):
+ source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
- self.builder.build(
- source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=ARM64
- )
+ self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime, architecture=ARM64)
expected_files = {
"Amazon.Lambda.Core.dll",
@@ -121,14 +133,18 @@ def test_with_defaults_file_arm64(self):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
- self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64", version="6.0")
+ self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64", version)
- def test_with_custom_runtime(self):
- source_dir = os.path.join(self.TEST_DATA_FOLDER, "CustomRuntime6")
+ @parameterized.expand(
+ [
+ ("dotnet6", "6.0", "CustomRuntime6"),
+ ("dotnet8", "8.0", "CustomRuntime8"),
+ ]
+ )
+ def test_with_custom_runtime(self, runtime, version, test_project):
+ source_dir = os.path.join(self.TEST_DATA_FOLDER, test_project)
- self.builder.build(
- source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=X86_64
- )
+ self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime, architecture=X86_64)
expected_files = {
"Amazon.Lambda.Core.dll",
@@ -144,7 +160,7 @@ def test_with_custom_runtime(self):
output_files = set(os.listdir(self.artifacts_dir))
self.assertEqual(expected_files, output_files)
- self.verify_architecture("bootstrap.deps.json", "linux-x64", version="6.0")
+ self.verify_architecture("bootstrap.deps.json", "linux-x64", version)
# Execute permissions are required for custom runtimes which bootstrap themselves, otherwise `sam local invoke`
# won't have permission to run the file
self.verify_execute_permissions("bootstrap")
diff --git a/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/CustomRuntime8.csproj b/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/CustomRuntime8.csproj
new file mode 100644
index 000000000..5dc8d0f1b
--- /dev/null
+++ b/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/CustomRuntime8.csproj
@@ -0,0 +1,17 @@
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ Lambda
+ bootstrap
+ true
+ true
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/Function.cs b/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/Function.cs
new file mode 100644
index 000000000..0bbad05ac
--- /dev/null
+++ b/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/Function.cs
@@ -0,0 +1,21 @@
+using Amazon.Lambda.Core;
+using Amazon.Lambda.RuntimeSupport;
+using Amazon.Lambda.Serialization.SystemTextJson;
+
+namespace CustomRuntime6;
+
+public class Function
+{
+ private static async Task Main(string[] args)
+ {
+ Func handler = FunctionHandler;
+ await LambdaBootstrapBuilder.Create(handler, new DefaultLambdaJsonSerializer())
+ .Build()
+ .RunAsync();
+ }
+
+ public static string FunctionHandler(string input, ILambdaContext context)
+ {
+ return input.ToUpper();
+ }
+}
\ No newline at end of file
diff --git a/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/aws-lambda-tools-defaults.json b/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/aws-lambda-tools-defaults.json
new file mode 100644
index 000000000..9c44274ae
--- /dev/null
+++ b/tests/integration/workflows/dotnet_clipackage/testdata/CustomRuntime8/aws-lambda-tools-defaults.json
@@ -0,0 +1,16 @@
+{
+ "Information": [
+ "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
+ "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
+ "dotnet lambda help",
+ "All the command line options for the Lambda command can be specified in this file."
+ ],
+ "profile": "",
+ "region": "",
+ "configuration": "Release",
+ "function-runtime": "provided.al2",
+ "function-memory-size": 256,
+ "function-timeout": 30,
+ "function-handler": "bootstrap",
+ "msbuild-parameters": "--self-contained true"
+}
\ No newline at end of file
diff --git a/tests/integration/workflows/dotnet_clipackage/testdata/RequireParameters/RequireParameters.cs b/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/Function.cs
similarity index 96%
rename from tests/integration/workflows/dotnet_clipackage/testdata/RequireParameters/RequireParameters.cs
rename to tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/Function.cs
index 602632404..23fc86994 100644
--- a/tests/integration/workflows/dotnet_clipackage/testdata/RequireParameters/RequireParameters.cs
+++ b/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/Function.cs
@@ -8,7 +8,7 @@
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
-namespace RequireParameters
+namespace WithDefaultsFile
{
public class Function
{
diff --git a/tests/integration/workflows/dotnet_clipackage/testdata/RequireParameters/RequireParameters.csproj b/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/WithDefaultsFile.csproj
similarity index 89%
rename from tests/integration/workflows/dotnet_clipackage/testdata/RequireParameters/RequireParameters.csproj
rename to tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/WithDefaultsFile.csproj
index 5db764810..cdb851832 100644
--- a/tests/integration/workflows/dotnet_clipackage/testdata/RequireParameters/RequireParameters.csproj
+++ b/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/WithDefaultsFile.csproj
@@ -1,6 +1,6 @@
- net6.0
+ net8.0
true
Lambda
diff --git a/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/aws-lambda-tools-defaults.json b/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/aws-lambda-tools-defaults.json
new file mode 100644
index 000000000..81e94b11d
--- /dev/null
+++ b/tests/integration/workflows/dotnet_clipackage/testdata/WithDefaultsFile8/aws-lambda-tools-defaults.json
@@ -0,0 +1,16 @@
+{
+ "Information": [
+ "This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
+ "To learn more about the Lambda commands with the .NET Core CLI execute the following command at the command line in the project root directory.",
+ "dotnet lambda help",
+ "All the command line options for the Lambda command can be specified in this file."
+ ],
+ "profile": "",
+ "region": "",
+ "configuration": "Release",
+ "framework": "net8.0",
+ "function-runtime": "dotnet8",
+ "function-memory-size": 256,
+ "function-timeout": 30,
+ "function-handler": "WithDefaultsFile::WithDefaultsFile.Function::FunctionHandler"
+}
\ No newline at end of file
diff --git a/tests/unit/workflows/dotnet_clipackage/test_actions.py b/tests/unit/workflows/dotnet_clipackage/test_actions.py
index 2005155ca..c9e54a518 100644
--- a/tests/unit/workflows/dotnet_clipackage/test_actions.py
+++ b/tests/unit/workflows/dotnet_clipackage/test_actions.py
@@ -4,6 +4,7 @@
import platform
from concurrent.futures import ThreadPoolExecutor
from unittest.mock import patch
+from parameterized import parameterized
from aws_lambda_builders.actions import ActionFailedError
from aws_lambda_builders.architecture import ARM64, X86_64
@@ -154,9 +155,15 @@ def test_build_package_arm64(self):
cwd="/source_dir",
)
- def test_build_package_arguments(self):
+ @parameterized.expand(
+ [
+ ("net6.0"),
+ ("net8.0"),
+ ]
+ )
+ def test_build_package_arguments(self, dotnet_version):
mode = "Release"
- options = {"--framework": "net6.0"}
+ options = {"--framework": dotnet_version}
action = RunPackageAction(
self.source_dir, self.subprocess_dotnet, self.artifacts_dir, options, mode, os_utils=self.os_utils
)
@@ -176,7 +183,7 @@ def test_build_package_arguments(self):
"--msbuild-parameters",
"--runtime linux-x64",
"--framework",
- "net6.0",
+ dotnet_version,
],
cwd="/source_dir",
)