英文:
VS Code doesn't find expected dotnet SDK
问题
我在Linux Mint(21.1 Vera)上运行VS Code。
我正在使用C#开发一个小的dotnet Web应用程序。
一切都很顺利,直到(我相信)进行了dotnet sdk更新。
我可以从终端看到当前的dotnet版本:7.0.302
dotnet --list-sdks
7.0.302 [/usr/share/dotnet/sdk]
当尝试运行或构建在更新之前正常工作的项目时,我收到以下消息:
dotnet run
您必须安装或更新.NET才能运行此应用程序。
应用程序:/usr/share/dotnet/sdk/7.0.302/dotnet.dll
架构:x64
框架:'Microsoft.NETCore.App',版本'7.0.5'(x64)
.NET位置:/usr/share/dotnet/
未找到任何框架。
了解框架解析:
https://aka.ms/dotnet/app-launch-failed
因此,我按照最后一个链接来安装丢失的框架。
最终,它会执行一个安装SDK的命令:
sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-7.0
它不允许我指定7.0.5,因此它只会重新安装最新版本,即7.0.302,我回到了原点。
我找到了一个安装特定版本7.0.5的命令,但它报错:
./dotnet-install.sh --architecture x64 --install-dir /usr/share/dotnet/ --runtime dotnet --version 7.0.5
dotnet_install: 错误:无法验证已安装的.NET Core Runtime
的版本。
安装来源:https://dotnetcli.azureedge.net/dotnet/Runtime/7.0.5/dotnet-runtime-7.0.5-linux-x64.tar.gz。
安装位置:/usr/share/dotnet/。
请在https://github.com/dotnet/install-scripts/issues上报告错误。
dotnet_install: 错误:安装带有版本=7.0.5的.NET Core Runtime
时出错。
它找不到.NET运行时,因为我没有安装(也从未安装过)。但据我了解,SDK已经包含了运行时?
理想情况下,我希望只需告诉VS Code使用7.0.302,但如果我能在任何地方找到它,我也愿意使用7.0.5。我仍然没有成功...
有人能提出解决方案吗?
英文:
I am running VS Code on Linux Mint ( 21.1 Vera ).
I am developing a small dotnet web app using C#.
Everything was running fine until ( I believe ) there was a dotnet sdk update.
I can see the current dotnet version from the terminal: 7.0.302
dotnet --list-sdks
7.0.302 [/usr/share/dotnet/sdk]
When trying to run or build the project that was working until the update, I get this message:
dotnet run
You must install or update .NET to run this application.
App: /usr/share/dotnet/sdk/7.0.302/dotnet.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '7.0.5' (x64)
.NET location: /usr/share/dotnet/
No frameworks were found.
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App& framework_version=7.0.5&arch=x64&rid=linuxmint.21.1-x64
So I follow the last link to install the missing framework.
It eventually takes to a command to install the SDK:
sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-7.0
It doesn't let me specify 7.0.5, so it just reinstalls the most recent version, which is 7.0.302, and I am back to square one.
I have found a command to install 7.0.5 specifically, but it throws an error:
./dotnet-install.sh --architecture x64 --install-dir /usr/share/dotnet/ --runtime dotnet --version 7.0.5
dotnet_install: Error: Failed to verify the version of installed `.NET Core Runtime`.
Installation source: https://dotnetcli.azureedge.net/dotnet/Runtime/7.0.5/dotnet-runtime-7.0.5-linux-x64.tar.gz.
Installation location: /usr/share/dotnet/.
Report the bug at https://github.com/dotnet/install-scripts/issues.
dotnet_install: Error: `.NET Core Runtime` with version = 7.0.5 failed to install with an error.
It doesn't find a .NET runtime because I don't have one installed ( and never have ). But, from what I understand, SDK already included a runtime?
Ideally I would like to just tell VS Code to use 7.0.302, but happy to stick to 7.0.5 if I can find it anywhere. I still haven't managed...
Can anyone suggest a solution?
答案1
得分: 0
我在发布问题几分钟后找到了解决方案...
对我有效的步骤来自 https://github.com/dotnet/core/issues/7699
这些步骤来自混合状态方案1。
在此复制以防将来链接不再可用:
删除所有 .NET 包
sudo apt remove --purge dotnet*
sudo apt remove --purge aspnetcore*
从 APT 中删除 PMC 存储库,可以使用任何典型的方法,例如通过删除 repo .list 文件
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
更新 APT
sudo apt update
安装 .NET SDK 6.0
sudo apt install dotnet-sdk-6.0
英文:
I found the solution to the problem a few minutes after posting the issue...
The steps that worked for me are from https://github.com/dotnet/core/issues/7699
The steps are from mixed state scenario 1.
Copied here in case the link is no longer available in the future:
Remove all .NET packages
sudo apt remove --purge dotnet*
sudo apt remove --purge aspnetcore*
Delete PMC repository from APT, using any of the typical methods, for instance by deleting the repo .list file
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
Update APT
sudo apt update
Install .NET SDK 6.0
sudo apt install dotnet-sdk-6.0
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论