You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Intel Mac上xUnit-cli无法识别已安装dotnet的问题排查

Intel Mac上XUnit命令行执行失败的配置问题

问题场景

  • 环境:Intel芯片Mac,Xamarin Forms项目,采用XUnit进行单元测试
  • 现象:IDE内测试可正常运行,但命令行执行失败
  • 操作:已安装dotnet 6.0.110并配置到PATH,通过dotnet tool install -g xunit-cli安装工具并添加到PATH,运行时触发以下错误:
You must install .NET to run this application.

App: /Users/luke/.dotnet/tools/xunit
Architecture: x64
App host version: 6.0.10
.NET location: Not found

Learn about runtime installation:
https://aka.ms/dotnet/app-launch-failed

Download the .NET runtime:
https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=osx.13-x64&apphost_version=6.0.10

可能的原因及解决步骤

  • 运行时版本不匹配
    错误提示的app host版本为6.0.10,与你安装的dotnet 6.0.110存在小版本差异。可尝试安装6.0.10版本的运行时,或重新安装xunit-cli工具,确保其与当前dotnet版本兼容。

  • PATH配置优先级问题
    检查PATH环境变量,确保~/.dotnet/tools位于系统默认dotnet路径之前。执行echo $PATH查看顺序,调整后重启终端再尝试运行命令。

  • 工具安装损坏
    卸载现有xunit-cli并清理残留文件,重新安装:

    dotnet tool uninstall -g xunit-cli
    rm -rf ~/.dotnet/tools/xunit
    dotnet tool install -g xunit-cli
    
  • 改用官方测试命令
    无需依赖xunit-cli,直接使用dotnet官方命令即可运行测试,兼容性更佳:

    dotnet test
    

    该命令会自动识别项目中的XUnit框架,执行所有测试用例。

内容的提问来源于stack exchange,提问作者TheLukeMcCarthy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 12:10:22