Skip to content

Commit 9b07181

Browse files
hawflauaboelhamdmndeveci
authored
Support for dotnet6 (#26) (#333)
* support for dotnet6 * fix tests * Fix black format issue * Install dotnet6 in appveyor env Co-authored-by: Mehmet Nuri Deveci <[email protected]> Co-authored-by: Wing Fung Lau <[email protected]> Co-authored-by: Aboelhamd Aly <[email protected]> Co-authored-by: Mehmet Nuri Deveci <[email protected]>
1 parent 334ee50 commit 9b07181

File tree

6 files changed

+134
-2
lines changed

6 files changed

+134
-2
lines changed

.appveyor.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ for:
7575
# setup make
7676
- "choco install make"
7777

78+
# install dotnet6
79+
- 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\\'\""
80+
7881
# Echo final Path
7982
- "echo %PATH%"
8083

aws_lambda_builders/validator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"java11": [ARM64, X86_64],
2323
"go1.x": [ARM64, X86_64],
2424
"dotnetcore3.1": [ARM64, X86_64],
25+
"dotnet6": [ARM64, X86_64],
2526
"provided": [ARM64, X86_64],
2627
}
2728

tests/integration/workflows/dotnet_clipackage/test_dotnet.py

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ def tearDown(self):
3131
shutil.rmtree(self.artifacts_dir)
3232
shutil.rmtree(self.scratch_dir)
3333

34-
def verify_architecture(self, deps_file_name, expected_architecture):
34+
def verify_architecture(self, deps_file_name, expected_architecture, version=None):
3535
deps_file = pathlib.Path(self.artifacts_dir, deps_file_name)
3636

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

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

@@ -118,3 +118,77 @@ def test_with_defaults_file_arm64(self):
118118

119119
self.assertEqual(expected_files, output_files)
120120
self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64")
121+
122+
123+
class TestDotnet6(TestDotnetBase):
124+
"""
125+
Tests for dotnet 6
126+
"""
127+
128+
def setUp(self):
129+
super(TestDotnet6, self).setUp()
130+
self.runtime = "dotnet6"
131+
132+
def test_with_defaults_file(self):
133+
source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")
134+
135+
self.builder.build(source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime)
136+
137+
expected_files = {
138+
"Amazon.Lambda.Core.dll",
139+
"Amazon.Lambda.Serialization.Json.dll",
140+
"Newtonsoft.Json.dll",
141+
"WithDefaultsFile.deps.json",
142+
"WithDefaultsFile.dll",
143+
"WithDefaultsFile.pdb",
144+
"WithDefaultsFile.runtimeconfig.json",
145+
}
146+
147+
output_files = set(os.listdir(self.artifacts_dir))
148+
149+
self.assertEqual(expected_files, output_files)
150+
self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version="6.0")
151+
152+
def test_with_defaults_file_x86(self):
153+
source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")
154+
155+
self.builder.build(
156+
source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=X86_64
157+
)
158+
159+
expected_files = {
160+
"Amazon.Lambda.Core.dll",
161+
"Amazon.Lambda.Serialization.Json.dll",
162+
"Newtonsoft.Json.dll",
163+
"WithDefaultsFile.deps.json",
164+
"WithDefaultsFile.dll",
165+
"WithDefaultsFile.pdb",
166+
"WithDefaultsFile.runtimeconfig.json",
167+
}
168+
169+
output_files = set(os.listdir(self.artifacts_dir))
170+
171+
self.assertEqual(expected_files, output_files)
172+
self.verify_architecture("WithDefaultsFile.deps.json", "linux-x64", version="6.0")
173+
174+
def test_with_defaults_file_arm64(self):
175+
source_dir = os.path.join(self.TEST_DATA_FOLDER, "WithDefaultsFile6")
176+
177+
self.builder.build(
178+
source_dir, self.artifacts_dir, self.scratch_dir, source_dir, runtime=self.runtime, architecture=ARM64
179+
)
180+
181+
expected_files = {
182+
"Amazon.Lambda.Core.dll",
183+
"Amazon.Lambda.Serialization.Json.dll",
184+
"Newtonsoft.Json.dll",
185+
"WithDefaultsFile.deps.json",
186+
"WithDefaultsFile.dll",
187+
"WithDefaultsFile.pdb",
188+
"WithDefaultsFile.runtimeconfig.json",
189+
}
190+
191+
output_files = set(os.listdir(self.artifacts_dir))
192+
193+
self.assertEqual(expected_files, output_files)
194+
self.verify_architecture("WithDefaultsFile.deps.json", "linux-arm64", version="6.0")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
using Amazon.Lambda.Core;
7+
8+
// Assembly attribute to enable the Lambda function's JSON input to be converted into a .NET class.
9+
[assembly: LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))]
10+
11+
namespace WithDefaultsFile
12+
{
13+
public class Function
14+
{
15+
16+
/// <summary>
17+
/// A simple function that takes a string and does a ToUpper
18+
/// </summary>
19+
/// <param name="input"></param>
20+
/// <param name="context"></param>
21+
/// <returns></returns>
22+
public string FunctionHandler(string input, ILambdaContext context)
23+
{
24+
return input?.ToUpper();
25+
}
26+
}
27+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
5+
<AWSProjectType>Lambda</AWSProjectType>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
9+
<PackageReference Include="Amazon.Lambda.Serialization.Json" Version="1.4.0" />
10+
</ItemGroup>
11+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Information": [
3+
"This file provides default values for the deployment wizard inside Visual Studio and the AWS Lambda commands added to the .NET Core CLI.",
4+
"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.",
5+
"dotnet lambda help",
6+
"All the command line options for the Lambda command can be specified in this file."
7+
],
8+
"profile": "",
9+
"region": "",
10+
"configuration": "Release",
11+
"framework": "net6.0",
12+
"function-runtime": "dotnet6",
13+
"function-memory-size": 256,
14+
"function-timeout": 30,
15+
"function-handler": "WithDefaultsFile::WithDefaultsFile.Function::FunctionHandler"
16+
}

0 commit comments

Comments
 (0)