在 CentOS 8 上安装 dotnet/core/aspnet:3.1 时出错 - 文件夹 [/usr/share/dotnet/host/fxr] 不包含任何版本编号的子文件夹

Error when install dotnet/core/aspnet:3.1 on CentOS 8 - Folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders

喜欢dotnet/dotnet-docker#1537 但我在独立机器上的 CenOS 8(不是 Docker)上有同样的错误。 使用 2020 年 12 月 23 日的最新更新清理新的 CentOS 8。 在控制台中:

sudo dnf install aspnetcore-runtime-3.1 - 好的

dotnet - OK(使用手册显示)

dotnet --info - 错误:

A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders

dotnet --list-runtimes - 错误: A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders

dotnet *.dll - 错误: A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders

文件夹 /usr/share/dotnet/host/fxr 确实是空的。尝试安装 SDK - 无效

我将系统更新到 Fedora 32 后遇到了同样的问题。问题是,我之前安装了 dotnet-runtime-2.1,但 Fedora 32 附带了 3.1。

如果您的 dotnet 应用程序与 3.1 兼容,您只需卸载旧的运行时即可。我就是这样做的:

  1. 检查已安装的 dotnet 运行时:
$ rpm -qa | grep dotnet
dotnet-runtime-2.1-2.1.12-1.x86_64
dotnet-runtime-deps-2.1-2.1.12-1.x86_64
dotnet-hostfxr-2.1-2.1.12-1.x86_64
dotnet-host-3.1.10-1.fc32.x86_64

就我而言,2.1 版是我自己安装的。 3.1 已被系统安装(标记为fc32)

  1. 删除旧版本:
dnf remove dotnet-runtime-2.1
  1. 要安装 2.1,我之前必须添加 Microsoft 存储库,现在不再需要了:
rm /etc/yum.repos.d/microsoft-prod.repo
  1. 出于某种未知原因,卸载 2.1 也会卸载 3.1。像往常一样安装它:
 dnf install dotnet-runtime-3.1
  1. dotnet --info 应该又可以工作了。

如需更多信息或您的应用程序需要 dotnet 2.1:

https://github.com/dotnet/core/issues/4655

如果dotnet sdk是5.0版本

步骤 1.- 删除 sdk

sudo dnf remove dotnet-sdk-5.0

步骤 2.- 删除文件夹

sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/bin/dotnet
sudo rm -rf /etc/yum.repos.d/microsoft-prod.repo

步骤 4.- 清理和升级。

sudo dnf clean all
sudo dnf upgrade

步骤 5.- 重启系统

sudo init 6

第 6 步.- 最后

sudo dnf install dotnet-sdk-5.0