【问题标题】:dotnet run x.csproj "... libhostfxr.dylib could not be found."dotnet run x.csproj “...找不到 libhostfxr.dylib。”
【发布时间】:2021-12-30 04:16:22
【问题描述】:

在安装了 .NET 6.0 的 Mac 上运行 .NET Core 项目会导致一个奇怪的错误。

 lukepuplett@Lukes-Air > ~/Documents/Git/Repo/src/Corp.App.Mvc > > master ± > dotnet run Corp.App.Mvc.csproj 
A fatal error occurred. The required library libhostfxr.dylib could not be found.
If this is a self-contained application, that library should exist in [/Users/lukepuplett/Documents/Git/Repo/src/Corp.App.Mvc/bin/Debug/net5.0/].
If this is a framework-dependent application, install the runtime in the global location [/usr/local/share/dotnet/x64] or use the DOTNET_ROOT environment variable to specify the runtime location or register the runtime location in [/etc/dotnet/install_location].

The .NET runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.11.1-x64&apphost_version=5.0.12
 

请注意,项目构建良好。

已安装 macOS Monterey、Apple Silicon M1 和 .NET 6.0。

【问题讨论】:

    标签: .net-6.0


    【解决方案1】:

    当项目面向较旧的 .NET Core 版本时,可能会发生这种情况。该错误令人困惑,因为项目可能构建良好,并且您期望得到更准确的消息。

    直接执行编译后的二进制文件时可以看到更好的消息,见下文。

     lukepuplett@Lukes-Air > ~/Documents/Git/Repo/src/Corp.App.Mvc/bin/Debug/net5.0 > > master ± > dotnet Corp.App.Mvc.dll
    It was not possible to find any compatible framework version
    The framework 'Microsoft.AspNetCore.App', version '5.0.0' (arm64) was not found.
      - The following frameworks were found:
          6.0.0 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
    
    You can resolve the problem by installing the specified framework and/or SDK.
    
    The specified framework can be found at:
      - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=5.0.0&arch=arm64&rid=osx.11.1-arm64
    

    例如,当您从针对 .NET Core 5 的 Git 存储库中提取代码时,可能会出现此问题。

    【讨论】:

      猜你喜欢
      • 2019-09-26
      • 2023-01-15
      • 2022-01-23
      • 1970-01-01
      • 2023-02-05
      • 1970-01-01
      • 2019-11-13
      • 1970-01-01
      • 2019-08-17
      相关资源
      最近更新 更多