Closed tparvi closed 1 week ago
Had some lunch and came up with the following workaround for this issue. Say your lambda function project is lambdatest.csproj
. Edit it and add something like this:
<Target Name="CustomTarget" AfterTargets="_PublishNoBuildAlternative">
<Delete Files="$(PublishDir)\ClassLibrary1.runtimeconfig.json"/>
<Delete Files="$(PublishDir)\ClassLibrary1.deps.json"/>
</Target>
This will delete the runtime config and deps file for the class library and after that everything works. After this you are only left with single runtime config and deps file for the actual lambda function.
This is the entry point https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.RuntimeSupport/lambda-entrypoint.sh. If LAMBDA_DOTNET_MAIN_ASSEMBLY
not set then it seems to pick the first one.
@tparvi @pekkah Thanks for your inputs. The issue is easily reproducible.
We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.
No auto close.
The issue appears to be resolved when using .NET 6 container image template. .NET 5.0
has reached end-of-life per https://dotnet.microsoft.com/en-us/download/dotnet/5.0. Please test using .NET 6 and confirm if the issue is still reproducible.
Thanks, Ashish
This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.
Description
If you create new lambda project, add a reference to .net 5 class library and deploy it to AWS it fails to run there. This has also been reported in the forums: https://forums.aws.amazon.com/thread.jspa?threadID=337142&tstart=0
Note that running this locally using Mock Lambda Test Tool succeeds.
Reproduction Steps
Using Windows 10, .NET 5 (dotnet --version reports 5.0.201), Visual Studio 2019 v16.9.3)
dotnet tool update -g Amazon.Lambda.Tools
)dotnet new -i Amazon.Lambda.Templates
)dotnet new lambda.image.EmptyFunction
)Function.cs
) to call that method and return the resultLogs
When you execute the function you'll see the following error. It seems that the entrypoint or application that aws tries to run is a json file instead of the dll.
Below is the log file from when executing publish from Visual Studio when I select the lambdatest.csproj in VS and click "Publish to AWS Lambda..."
Below is the contents of aws-lambda-tools-defaults.json file
Below you can see the lambdatest.deps.json file contents (this is in the publish folder on my machine)
Below you can see the contents of lambdatest.runtimeconfig.json file
The publish folder contains following files. Not sure why there is a runtimeconfig file for ClassLibrary1.dll
Environment
Resolution
This is a :bug: bug-report