英文:
Application on Ubuntu Looking for .net Runtimes in Different Places
问题
我在Ubuntu上使用VS Code编写AWS Lambda函数,并使用AWS Mock Lambda工具进行调试。
当我运行'dotnet --info'时,我看到以下内容:
.NET Core运行时已安装:
Microsoft.AspNetCore.App 3.1.32 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
我不确定为什么有两个文件夹,但这造成了问题。
当我在VS Code中运行项目时,它是dotnet 6.0,并且正确地在/usr/share/dotnet/shared/Microsoft.NETCore.App中找到了运行时。我已经多次使用./dotnet-install.sh重新安装了dotenet 6,它总是安装在那里。
但当我使用模拟Lambda工具运行它时,代码在dotnet 6运行时下构建没有问题,但当模拟Lambda工具尝试加载时,它抛出以下错误:
未找到框架'Microsoft.AspNetCore.App',版本'6.0.0'。
- 找到以下框架:
3.1.32 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
所以VS Code从这里获取运行时:/usr/share/dotnet/shared/Microsoft.NETCore.App(正确)
但AWS Mock Lambda在这里查找:/usr/share/dotnet/shared/Microsoft.AspNetCore.App
如果我从/usr/share/dotnet/shared/Microsoft.AspNetCore.App中删除运行时,它会说找不到任何运行时。
有没有办法告诉Lambda工具查找正确的文件夹?或者在Lambda工具正在查找的文件夹中安装dotnet 6?
这是我的VS Code中的launch.json配置:
{
"version": "0.2.0",
"configurations": [
{
"name": "Job Worker",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "dotnet-lambda-test-tool-6.0",
"args": [],
"cwd": "${workspaceFolder}/JobWorker",
"console": "internalConsole",
"stopAtEntry": false
},
]
}
英文:
I am on Ubuntu using VS Code to write an AWS lambda function and debugging it with the AWS Mock Lambda tool.
When I run 'dotnet --info' I see this:
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.32 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.14 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
I'm not sure why there are 2 folders, but it's creating a problem.
When I run VS Code, the project is dotnet 6.0, and it correctly finds that runtime in /usr/share/dotnet/shared/Microsoft.NETCore.App. I have reinstalled dotenet 6 several times using ./dotnet-install.sh and that is always where it is intstalled.
When I run it using the mock lambda tool, the code builds fine using the dotnet 6 runtime, but when the mock lambda tool tries to load, it throws this error:
The framework 'Microsoft.AspNetCore.App', version '6.0.0' was not found.
- The following frameworks were found:
3.1.32 at [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
So VS Code it getting the runtime from: /usr/share/dotnet/shared/Microsoft.NETCore.App (correct)
But AWS Mock Lambda is looking in: /usr/share/dotnet/shared/Microsoft.AspNetCore.App
If I remove the runtime from /usr/share/dotnet/shared/Microsoft.AspNetCore.App, it says it cannot find any runtimes.
Is there a way I can tell the lambda tool to look in the correct folder? Or install dotnet 6 in the folder the lambda tool is look for it in?
This is my launch.json in VS Code:
{
"version": "0.2.0",
"configurations": [
{
"name": "Job Worker",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "dotnet-lambda-test-tool-6.0",
"args": [],
"cwd": "${workspaceFolder}/JobWorker",
"console": "internalConsole",
"stopAtEntry": false
},
]
}
答案1
得分: 1
描述中展示了一个关于运行时的常见误解。
确实存在.NET Core运行时Microsoft.NETCore.App
和ASP.NET Core运行时Microsoft.AspNetCore.App
,因此您应该安装ASP.NET Core 6运行时以满足要求,
sudo apt-get install -y aspnetcore-runtime-6.0
链接:https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
英文:
The description shows a common misconception about the runtimes.
There are indeed the .NET Core runtime Microsoft.NETCore.App
and the ASP.NET Core runtime Microsoft.AspNetCore.App
, so you should install ASP.NET Core 6 runtime to meet the requirement,
sudo apt-get install -y aspnetcore-runtime-6.0
https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论