我正在尝试设置环境以在我的 Ubuntu 20.04 计算机上编写 Unity 项目。
我想使用 VSCode 来编写我的 C# 代码。根据需要,我安装了 .NET SDK 5.0.201。
因此,我尝试运行一些代码,但 VSCode 似乎无法识别我的 .NET 安装。每次打开 VSCode 时,都会收到以下消息:
The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.
而且(主要问题),我的 C# 代码没有自动完成功能。
我真的不明白这里有什么问题。 .NET 在我的终端中被正确识别(ubuntu 终端和 VSCode 中的终端)
>> dotnet --info
.NET SDK (reflecting any global.json):
Version: 5.0.201
Commit: a09bd5c86c
Runtime Environment:
OS Name: ubuntu
OS Version: 20.04
OS Platform: Linux
RID: ubuntu.20.04-x64
Base Path: /snap/dotnet-sdk/116/sdk/5.0.201/
Host (useful for support):
Version: 5.0.4
Commit: f27d337295
.NET SDKs installed:
5.0.201 [/snap/dotnet-sdk/116/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.4 [/snap/dotnet-sdk/116/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.4 [/snap/dotnet-sdk/116/shared/Microsoft.NETCore.App]
我在这里遗漏了什么?
编辑
C# 扩展也无法加载并给我以下消息:
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/path/to/my/project/Assembly-CSharp.csproj'.
/path/to/my/project/Assembly-CSharp.csproj
/home/me/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(1180,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
答案 0 :(得分:0)
我终于找到了答案!
在 VSCode 设置中,我配置了
"omnisharp.useGlobalMono": "always"
代替
"omnisharp.useGlobalMono": "auto"
它成功了