Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ for:
# setup make
- "choco install make"

# install dotnet6
- ps: "&powershell -NoProfile -ExecutionPolicy unrestricted -Command \"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) -Version 6.0.200 -InstallDir 'C:\\Program Files\\dotnet\\'\""

# Echo final Path
- "echo %PATH%"

Expand Down
1 change: 1 addition & 0 deletions aws_lambda_builders/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"java11": [ARM64, X86_64],
"go1.x": [ARM64, X86_64],
"dotnetcore3.1": [ARM64, X86_64],
"dotnet6": [ARM64, X86_64],
"provided": [ARM64, X86_64],
}

Expand Down
78 changes: 76 additions & 2 deletions tests/integration/workflows/dotnet_clipackage/test_dotnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ def tearDown(self):
shutil.rmtree(self.artifacts_dir)
shutil.rmtree(self.scratch_dir)

def verify_architecture(self, deps_file_name, expected_architecture):
def verify_architecture(self, deps_file_name, expected_architecture, version=None):
deps_file = pathlib.Path(self.artifacts_dir, deps_file_name)

if not deps_file.exists():
self.fail("Failed verifying architecture, {} file not found".format(deps_file_name))

with open(str(deps_file)) as f:
deps_json = json.loads(f.read())
version = self.runtime[-3:]
version = version or self.runtime[-3:]
target_name = ".NETCoreApp,Version=v{}/{}".format(version, expected_architecture)
target = deps_json.get("runtimeTarget").get("name")

Expand Down Expand Up @@ -118,3 +118,77 @@ def test_with_defaults_file_arm64(self):

self.assertEqual(expected_files, output_files)
self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64")


class TestDotnet6(TestDotnetBase):
"""
Tests for dotnet 6
"""

def setUp(self):
super(TestDotnet6, self).setUp()
self.runtime = "dotnet6"

def test_with_defaults_file(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")

self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime)

expected_files = {
"Amazon.Lambda.Core.dll",
"Amazon.Lambda.Serialization.Json.dll",
"Newtonsoft.Json.dll",
"WithDefaultsFile.deps.json",
"WithDefaultsFile.dll",
"WithDefaultsFile.pdb",
"WithDefaultsFile.runtimeconfig.json",
}

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")

def test_with_defaults_file_x86(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")

self.builder.build(
source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=X86_64
)

expected_files = {
"Amazon.Lambda.Core.dll",
"Amazon.Lambda.Serialization.Json.dll",
"Newtonsoft.Json.dll",
"WithDefaultsFile.deps.json",
"WithDefaultsFile.dll",
"WithDefaultsFile.pdb",
"WithDefaultsFile.runtimeconfig.json",
}

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")

def test_with_defaults_file_arm64(self):
source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")

self.builder.build(
source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=ARM64
)

expected_files = {
"Amazon.Lambda.Core.dll",
"Amazon.Lambda.Serialization.Json.dll",
"Newtonsoft.Json.dll",
"WithDefaultsFile.deps.json",
"WithDefaultsFile.dll",
"WithDefaultsFile.pdb",
"WithDefaultsFile.runtimeconfig.json",
}

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")
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Amazon.Lambda.Core;

// 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 WithDefaultsFile
{
public class Function
{

/// <summary>
/// A simple function that takes a string and does a ToUpper
/// </summary>
/// <param name="input"></param>
/// <param name="context"></param>
/// <returns></returns>
public string FunctionHandler(string input, ILambdaContext context)
{
return input?.ToUpper();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.4.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -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": "net6.0",
"function-runtime": "dotnet6",
"function-memory-size": 256,
"function-timeout": 30,
"function-handler": "WithDefaultsFile::WithDefaultsFile.Function::FunctionHandler"
}