Skip to content

Commit

Permalink
feat: Update .net examples to .NET 6 (serverless#682)
Browse files Browse the repository at this point in the history
  • Loading branch information
slang25 authored Feb 27, 2022
1 parent 765abf6 commit 0ce3277
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 42 deletions.
44 changes: 21 additions & 23 deletions legacy/aws-csharp/Handler.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
using Amazon.Lambda.Core;

[assembly:LambdaSerializer(typeof(Amazon.Lambda.Serialization.SystemTextJson.DefaultLambdaJsonSerializer))]
namespace AwsDotnetCsharp

namespace AwsDotnetCsharp;
public class Handler
{
public class Handler
public Response Hello(Request request)
{
public Response Hello(Request request)
{
return new Response("Go Serverless v1.0! Your function executed successfully!", request);
}
return new Response("Go Serverless v1.0! Your function executed successfully!", request);
}
}

public class Response
{
public string Message {get; set;}
public Request Request {get; set;}
public class Response
{
public string Message {get; set;}
public Request Request {get; set;}

public Response(string message, Request request){
Message = message;
Request = request;
}
}
public Response(string message, Request request)
{
Message = message;
Request = request;
}
}

public class Request
{
public string Key1 {get; set;}
public string Key2 {get; set;}
public string Key3 {get; set;}
}
public class Request
{
public string Key1 {get; set;}
public string Key2 {get; set;}
public string Key3 {get; set;}
}
14 changes: 10 additions & 4 deletions legacy/aws-csharp/aws-csharp.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>CsharpHandlers</AssemblyName>
<PackageId>aws-csharp</PackageId>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<PublishReadyToRun>true</PublishReadyToRun>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.0.1" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
<Using Include="Amazon.Lambda.Core" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions legacy/aws-csharp/build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dotnet restore
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
dotnet tool install -g Amazon.Lambda.Tools --framework net6.0
dotnet lambda package --configuration Release --framework net6.0 --output-package bin/Release/net6.0/hello.zip
4 changes: 2 additions & 2 deletions legacy/aws-csharp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ then
fi

dotnet restore
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
dotnet tool install -g Amazon.Lambda.Tools --framework net6.0
dotnet lambda package --configuration Release --framework net6.0 --output-package bin/Release/net6.0/hello.zip
4 changes: 2 additions & 2 deletions legacy/aws-csharp/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ frameworkVersion: '3'

provider:
name: aws
runtime: dotnetcore3.1
runtime: dotnet6

# you can overwrite defaults here
# stage: dev
Expand Down Expand Up @@ -59,7 +59,7 @@ functions:

# you can add packaging information here
package:
artifact: bin/Release/netcoreapp3.1/hello.zip
artifact: bin/Release/net6.0/hello.zip
# exclude:
# - exclude-me.js
# - exclude-me-dir/**
Expand Down
7 changes: 4 additions & 3 deletions legacy/aws-fsharp/aws-fsharp.fsproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>FsharpHandlers</AssemblyName>
<PackageId>aws-fsharp</PackageId>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

<ItemGroup>
<Compile Include="Handler.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.Core" Version="1.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.0.1" />
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.2.0" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions legacy/aws-fsharp/build.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dotnet restore
dotnet tool install -g Amazon.Lambda.Tools --framework netcoreapp3.1
dotnet tool install -g Amazon.Lambda.Tools --framework net6.0

dotnet lambda package --configuration Release --framework netcoreapp3.1 --output-package bin/Release/netcoreapp3.1/deploy-package.zip
dotnet lambda package --configuration Release --framework net6.0 --output-package bin/Release/net6.0/deploy-package.zip
4 changes: 2 additions & 2 deletions legacy/aws-fsharp/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ then
fi

dotnet restore
dotnet tool install -g Amazon.Lambda.Tools --framework netcoreapp3.1
dotnet lambda package --configuration Release --framework netcoreapp3.1 --output-package bin/Release/netcoreapp3.1/deploy-package.zip
dotnet tool install -g Amazon.Lambda.Tools --framework net6.0
dotnet lambda package --configuration Release --framework net6.0 --output-package bin/Release/net6.0/deploy-package.zip
4 changes: 2 additions & 2 deletions legacy/aws-fsharp/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ frameworkVersion: '3'

provider:
name: aws
runtime: dotnetcore3.1
runtime: dotnet6

# you can overwrite defaults here
# stage: dev
Expand Down Expand Up @@ -52,7 +52,7 @@ provider:

# you can add packaging information here
package:
artifact: bin/Release/netcoreapp3.1/deploy-package.zip
artifact: bin/Release/net6.0/deploy-package.zip
# exclude:
# - exclude-me.js
# - exclude-me-dir/**
Expand Down

0 comments on commit 0ce3277

Please sign in to comment.