无法在lambda中部署简单的hello-world:自包含程序包出现问题

时间:2020-02-12 10:45:50

标签: .net aws-lambda

对于aws和aws-lambda-cli,我是新闻。因此,我尝试根据以下文章制作一个简单的Hello World:http://www.philliphaydon.com/2017/03/15/part1-creating-a-good-old-hello-world-aws-csharp-lambda/。 在一开始的唯一区别是:我做了$ dotnet new classlib -n HelloWorldLambda而不是$ dotnet new classlib -n HelloWorldLambda -f netcoreapp1.0,因为我不想定位此版本。

对于编译,我使用以下命令行:dotnet lambda package,然后将zip上传到我的lambda并运行测试。 CloudWatch日志显示以下行:

"Failed to execute the Lambda function. The dotnet CLI failed to start with the provided deployment package.  Please check CloudWatch logs for this Lambda function to get detailed information about this failure.: LambdaException "
"Failed to run as a self-contained app. If this should be a framework-dependent app, specify the appropriate framework in /var/task/lambda-synchro-qbo.runtimeconfig.json." 
"A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/var/task/'."

我的lambda-synchro-qbo.runtimeconfig.json位于zip的根目录中,并包含以下内容:

{
  "runtimeOptions": {
    "tfm": "netstandard2.0"
  }
}

我怀疑我的软件包不是自包含的/可移植的,但是即使我像这样dotnet lambda package --msbuild-parameters "--self-contained"进行编译,我也遇到同样的问题。

我想念什么?

谢谢, 阿莫里

1 个答案:

答案 0 :(得分:0)

我将目标框架更改为.Net Core 3.1,就成功了。

我的runtimeconfig.json现在看起来像这样:

{
  "runtimeOptions": {
    "tfm": "netcoreapp3.1",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "3.1.0"
    }
  }
}
相关问题