我正在尝试在我的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#代码没有自动完成功能。
我真的不明白这里有什么问题。我的终端( ubuntu终端和VSCode内的终端)都能正确识别.NET
>> 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发布于 2021-04-06 19:38:10
我终于找到答案了!
在VSCode设置中,我配置了
"omnisharp.useGlobalMono": "always"而不是
"omnisharp.useGlobalMono": "auto"它起到了作用
https://stackoverflow.com/questions/66957235
复制相似问题