.Net Core(2.1)-Lambda函数可以正常工作,而在2.2中却不能工作吗? [英] .Net Core (2.1)- Lambda function does work while in 2.2 it doesn't?

查看:102
本文介绍了.Net Core(2.1)-Lambda函数可以正常工作,而在2.2中却不能工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用.Net Core 2.1创建了一个简单的空AWS Lambda函数:

I've created a simple empty AWS Lambda function using .Net Core 2.1 :

这是文件夹结构:

(这是 csproj )

还有一个FunctionHandler,它获取DI并调用一些虚拟方法:

And a FunctionHandler which gets DI and invoke some dummy method :

现在让我们运行模拟Lambda测试工具",我们可以看到它有效:

Now let's run the "Mock Lambda Test Tool" , we can see that it works :

那问题出在哪里?

我已在此处阅读支持:

I've read here that 2.2 is supported :

这意味着您现在可以使用.NET Core 2.2和更高版本编写Lambda函数. .NET Core 3.0预览. Amazon.Lambda.RuntimeSupport可作为 GitHub上的源代码,或作为NuGet包.

This means you can now author Lambda functions using .NET Core 2.2 and .NET Core 3.0 preview. Amazon.Lambda.RuntimeSupport is available as source code on GitHub, or as a NuGet package.

因此,我创建了一个新的空的lambda项目,但带有2.2:

And so , I've created a new empty lambda project but with 2.2 :

  • Here are the changes in the CSPROJ file
  • And here are the changes in the aws-lambda-tools-defaults.json file

相同的代码.但是现在当我运行"Mock Lambda测试工具"时,出现了一个错误:

Same code. But now when I run "Mock Lambda Test Tool" , I get an error :

AWS .NET Mock Lambda测试工具(0.9.2)发生未知错误,导致 进程退出:无法在以下位置找到deps.json文件 Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(字符串 目录)中 E:\ JenkinsWorkspaces \ Lam \ LambdaSandboxCoreCLRApi \ Tools \ LambdaTestTool \ Amazon.Lambda.TestTool \ Runtime \ LocalLambdaRuntime.cs:line 在Amazon.Lambda.TestTool.Program.Main(String [] args)中的50 E:\ JenkinsWorkspaces \ Lam \ LambdaSandboxCoreCLRApi \ Tools \ LambdaTestTool \ Amazon.Lambda.TestTool \ Program.cs:line 46按任意键退出

AWS .NET Mock Lambda Test Tool (0.9.2) Unknown error occurred causing process exit: Failed to find a deps.json file at Amazon.Lambda.TestTool.Runtime.LocalLambdaRuntime.Initialize(String directory) in E:\JenkinsWorkspaces\Lam\LambdaSandboxCoreCLRApi\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Runtime\LocalLambdaRuntime.cs:line 50 at Amazon.Lambda.TestTool.Program.Main(String[] args) in E:\JenkinsWorkspaces\Lam\LambdaSandboxCoreCLRApi\Tools\LambdaTestTool\Amazon.Lambda.TestTool\Program.cs:line 46 Press any key to exit

这是错误:

问题:

那是为什么?我在2.1中没有任何deps.json文件.

Why is that? I didn't have any deps.json file in 2.1 .

那么为什么在2.2中需要它? 另外,此路径在错误中显示的是什么:E:\JenkinsWorkspaces ...? 我没有詹金斯,也没有类似的东西.

So why do I need it in 2.2 ? Also, what is this path appearing in the error: E:\JenkinsWorkspaces... ? I don't have Jenkins nor something like it.

推荐答案

好吧,我已经找到了造成这种情况的原因(我不知道为什么发生在第一位),但这是事实.忍受我.

Well, I've found out the reason for this (I don't know why it happened at first place) but here it is. Bear with me.

当我创建一个2.1 lambda项目时,一切正常. (显然)

When I've created a 2.1 lambda project, everything was OK. ( obviously)

问题出在2.2项目上(针对2.2和2.2的nuget). (它显示了我在问题中显示的错误)

The problem was with 2.2 projects ( targeting 2.2 & nugets of 2.2). (which shows the error as I show in my question)

然后我想,如果我将创建一个2.1项目,然后更新(!)它的nuget并将目标更改为2.2怎么办? .........有效!

So then I thought, what if I'll create a 2.1 project and then update(!) its nugets and change target to 2.2 ? .........it worked!

这真的很奇怪.因为我希望不会.

This was really weird. Because I expected it not to.

然后我想,让我们比较一下2.2项目(无效)的文件系统和2.1项目(已更新为2.2项目(有效)的项目).

So then I thought, let's compare file system for a 2.2 project (which doesn't work), with a 2.1 project that was updated to a 2.2 project (which does work, surprisingly).

在右边是严格的2.2项目(无更新),在左边是已更新为2.2的项目:

On the right side, it's the strict 2.2 projects (no update), on the left it's the project that was UPDATED to 2.2 :

我已经注意到一些.Net core 2.1文件正在升级中,但不是严格的2.2版本,所以我想,我该如何获取那些丢失的文件?

I've noticed some .Net core 2.1 files that were in the upgrade but weren't in the strict 2.2 version, so I thought, how can I get those missing files ?

所以我已经(暂时)将项目目标更改为2.1:

So I've changed (temporarily) the project target to 2.1 :

然后我运行了构建

这导致显示2.1文件夹的文件:

This caused the files for the 2.1 folders to appear :

现在.............一切正常!!! :

And now ............. , all OK !!! :

这篇关于.Net Core(2.1)-Lambda函数可以正常工作,而在2.2中却不能工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆