发生致命错误。找不到所需的库 libhostfxr.dylib

问题描述 投票:0回答:4

我正在使用 .NET 5.0 开发 ASP.NET 项目。对于数据库创建,我运行了命令

dotnet tool install --global dotnet-ef

安装后,当我运行此命令时:

dotnet ef

我收到此错误:

发生致命错误。找不到所需的库 libhostfxr.dylib。如果这是一个独立的应用程序,则该库应存在于 [/Users/afshalathar/.dotnet/tools/.store/dotnet-ef/6.0.0/dotnet-ef/6.0.0/tools/netcoreapp3.1/ 中任何/]。

如果这是依赖于框架的应用程序,请将运行时安装在全局位置 [/usr/local/share/dotnet/x64] 或使用 DOTNET_ROOT 环境变量指定运行时位置或在 [/etc/ 中注册运行时位置dotnet/install_location]。

.NET 运行时可以在以下位置找到:

我使用的是 Mac M1

asp.net-core entity-framework-core asp.net-core-mvc
4个回答
8
投票

此处所述,首先卸载 dotnet-ef,然后使用

-a arm64
选项重新安装:

dotnet tool uninstall dotnet-ef --global  
dotnet tool install dotnet-ef --global -a arm64

这对我有用。


2
投票

聚会迟到了,但我在 M1 Macbook 上遇到了同样的问题。奇怪的是,以下步骤对我有用:

  1. sudo dotnet tool uninstall dotnet-ef --global
  2. dotnet tool update --global dotnet-ef

2
投票

更新

这可以永久解决问题:

dotnet tool uninstall dotnet-ef -g
dotnet tool install dotnet-ef -a arm64 -g

您也可以尝试在本地安装EF工具

CD 到您的源目录并执行以下操作:

dotnet new tool-manifest
dotnet tool install  dotnet-ef

这样,即使在.Net 5/6 arm64 上也能正常工作。

arm64 工具安装程序中存在引用 x64 版本的错误。


0
投票

我对这个错误非常绝望,直到我发现https://developercommunity.visualstudio.com/t/libhostfxrdylib-not-signed/909971.

我可以解决调用 dotnet ef 命令时的

libhostfxr.dylib
错误。只需完全更新我的 Visual Studio for Mac。

问题:此文件存在一些代码签名问题,macOS 只是将其移至某种隔离区(据我所知)

解决方案:打开 Visual Studio for Mac 并安装所有更新。

我首先在开发者社区上找到了该链接,然后认为它可能会起作用,而且确实如此。

如果这对您有帮助,您可能也会迷上 Jetbrains Rider。但是通过 Rider 安装 dotnet 并不能解决问题,而且安装此扩展 https://plugins.jetbrains.com/plugin/18147-entity-framework-core-ui 也没有解决问题。

如果您不介意在您的计算机上安装 Visual Studio for Mac,那么值得一试。

© www.soinside.com 2019 - 2024. All rights reserved.