From 46df82ea92ced3ba7542f6de5da6cfda73554ffc Mon Sep 17 00:00:00 2001 From: Joseph Woodward Date: Mon, 11 May 2020 11:26:42 +0100 Subject: [PATCH] feat(Templates): Update aws-csharp to .NET Core 3.1 (#7708) --- docker-compose.yml | 2 +- .../aws/examples/hello-world/csharp/README.md | 2 +- lib/plugins/create/templates/aws-csharp/Handler.cs | 10 +--------- .../create/templates/aws-csharp/aws-csharp.csproj | 10 +++------- lib/plugins/create/templates/aws-csharp/build.cmd | 3 ++- lib/plugins/create/templates/aws-csharp/build.sh | 3 ++- lib/plugins/create/templates/aws-csharp/serverless.yml | 4 ++-- 7 files changed, 12 insertions(+), 22 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ab3dc643f..5c051b5de 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -64,7 +64,7 @@ services: volumes: - ./tmp/serverless-integration-test-aws-scala-sbt:/app aws-csharp: - image: microsoft/dotnet:2.0-sdk + image: mcr.microsoft.com/dotnet/core/sdk:3.1 volumes: - ./tmp/serverless-integration-test-aws-csharp:/app aws-fsharp: diff --git a/docs/providers/aws/examples/hello-world/csharp/README.md b/docs/providers/aws/examples/hello-world/csharp/README.md index 4e041c4b0..42bac58c5 100644 --- a/docs/providers/aws/examples/hello-world/csharp/README.md +++ b/docs/providers/aws/examples/hello-world/csharp/README.md @@ -39,7 +39,7 @@ Using the `create` command we can specify one of the available [templates](https The `--path` or shorthand `-p` is the location to be created with the template service files. Change directories into this new folder. -## 2. Build using .NET Core 2.X CLI tools and create zip package +## 2. Build using .NET Core 3.1 CLI tools and create zip package ``` # Linux or Mac OS diff --git a/lib/plugins/create/templates/aws-csharp/Handler.cs b/lib/plugins/create/templates/aws-csharp/Handler.cs index cf4ff9549..4c526b5d0 100644 --- a/lib/plugins/create/templates/aws-csharp/Handler.cs +++ b/lib/plugins/create/templates/aws-csharp/Handler.cs @@ -1,8 +1,6 @@ using Amazon.Lambda.Core; -using System; - -[assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.Json.JsonSerializer))] +[assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))] namespace AwsDotnetCsharp { public class Handler @@ -29,11 +27,5 @@ namespace AwsDotnetCsharp public string Key1 {get; set;} public string Key2 {get; set;} public string Key3 {get; set;} - - public Request(string key1, string key2, string key3){ - Key1 = key1; - Key2 = key2; - Key3 = key3; - } } } diff --git a/lib/plugins/create/templates/aws-csharp/aws-csharp.csproj b/lib/plugins/create/templates/aws-csharp/aws-csharp.csproj index a4001e115..c5b12e6c0 100644 --- a/lib/plugins/create/templates/aws-csharp/aws-csharp.csproj +++ b/lib/plugins/create/templates/aws-csharp/aws-csharp.csproj @@ -1,19 +1,15 @@  - netcoreapp2.1 + netcoreapp3.1 true CsharpHandlers aws-csharp - - - - - - + + diff --git a/lib/plugins/create/templates/aws-csharp/build.cmd b/lib/plugins/create/templates/aws-csharp/build.cmd index cf1bf29bc..61537bee6 100644 --- a/lib/plugins/create/templates/aws-csharp/build.cmd +++ b/lib/plugins/create/templates/aws-csharp/build.cmd @@ -1,2 +1,3 @@ dotnet restore -dotnet lambda package --configuration release --framework netcoreapp2.1 --output-package bin/release/netcoreapp2.1/hello.zip +dotnet tool install -g Amazon.Lambda.Tools --framework netcoreapp3.1 +dotnet lambda package --configuration Release --framework netcoreapp3.1 --output-package bin/Release/netcoreapp3.1/hello.zip diff --git a/lib/plugins/create/templates/aws-csharp/build.sh b/lib/plugins/create/templates/aws-csharp/build.sh index 5769c5e0b..daadffd82 100755 --- a/lib/plugins/create/templates/aws-csharp/build.sh +++ b/lib/plugins/create/templates/aws-csharp/build.sh @@ -8,4 +8,5 @@ then fi dotnet restore -dotnet lambda package --configuration release --framework netcoreapp2.1 --output-package bin/release/netcoreapp2.1/hello.zip +dotnet tool install -g Amazon.Lambda.Tools --framework netcoreapp3.1 +dotnet lambda package --configuration Release --framework netcoreapp3.1 --output-package bin/Release/netcoreapp3.1/hello.zip diff --git a/lib/plugins/create/templates/aws-csharp/serverless.yml b/lib/plugins/create/templates/aws-csharp/serverless.yml index 2c6a21380..8d3042644 100644 --- a/lib/plugins/create/templates/aws-csharp/serverless.yml +++ b/lib/plugins/create/templates/aws-csharp/serverless.yml @@ -22,7 +22,7 @@ service: aws-csharp # NOTE: update this with your service name provider: name: aws - runtime: dotnetcore2.1 + runtime: dotnetcore3.1 # you can overwrite defaults here # stage: dev @@ -57,7 +57,7 @@ functions: # you can add packaging information here package: - artifact: bin/release/netcoreapp2.1/hello.zip + artifact: bin/Release/netcoreapp3.1/hello.zip # exclude: # - exclude-me.js # - exclude-me-dir/**