VS Code搭配Unity时OmniSharp无法识别已安装的Mono求助
更新说明
该问题已在OmniSharp 1.25.2版本更新中修复。
问题简述
已安装Mono,但VS Code仍提示需要Mono。
需求目标
希望在Unity中使用VS Code,并让代码补全(IntelliSense)功能正常工作。
报错信息
从Unity中打开C#项目到VS Code时,弹出提示需要安装Mono的窗口。
同时在VS Code的输出面板中看到以下错误:
OmniSharp failed to start because of missing requirements.
已确认的配置
- 已通过
which mono和mono --version确认Mono已安装 - 已通过
dotnet msbuild确认MSBuild已安装 - 已安装C#扩展,且
omnisharp.useModernNet设置为false - Unity外部脚本编辑器已设置为VS Code,且勾选了Embedded packages、Local packages和Packages from unknown sources
已尝试的解决方法
- Mono路径与默认路径不同,已尝试在VS Code中添加该路径,但无效果
- 在VS Code终端中执行
mono --version可正常显示版本信息 - 删除“Assembly-CSharp.csproj”和“.sln”文件后,在Unity中重新生成项目文件
- 重启电脑及相关程序
- 若将
omnisharp.useModernNet设置为true,VS Code输出面板会出现以下错误:
This project targets .NET version that requires reference assemblies that are not installed (e.g. .NET Framework). The most common solution is to make sure Mono is fully updated on your machine and that you are running the .NET Framework build of OmniSharp (e.g. 'omnisharp.useModernNet': false in C# Extension for VS Code).
系统及版本信息
- macOS 12.6.1
- Mac mini M1 2020
- VSCode 1.73.0
- Unity 2021.3.13f1
- dotnet 7.0.100
- mono 6.12.0.182
- MSBuild version 17.4.0+18d5aef85 for .NET
内容的提问来源于stack exchange,提问作者GW.Rodriguez
相关产品推荐
相关产品推荐

