0
votes

Not sure if the problem in my VS Code setup or in.NET.

After a long time of not using .NET on Mac, I installed the latest version.

dotnet --info

 Commit:    7feb845744

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/3.1.301/

Host (useful for support):
  Version: 3.1.5
  Commit:  65cd789777

.NET Core SDKs installed:
  1.0.0-preview2.1-003155 [/usr/local/share/dotnet/sdk]
  1.0.0-preview2-003131 [/usr/local/share/dotnet/sdk]
  1.0.0-preview2-003148 [/usr/local/share/dotnet/sdk]
  1.0.3 [/usr/local/share/dotnet/sdk]
  2.0.0 [/usr/local/share/dotnet/sdk]
  2.1.4 [/usr/local/share/dotnet/sdk]
  2.1.200 [/usr/local/share/dotnet/sdk]
  2.1.301 [/usr/local/share/dotnet/sdk]
  2.1.500 [/usr/local/share/dotnet/sdk]
  3.1.301 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.0-preview1-001100-00 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Then I ran:

dotnet new xunit -o leetcode
cd leetcode
code .

This starts VS Code. I open the unit test example and see that [Fact] is highlighted as an error: "The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [leetcode]"

And another problem points to ~/nuget/packages/microsoft.net.test.sdk/16.5.0/build/netcoreapp2.1. The same text "The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. [leetcode]"

dotnet buld, dotnet test, dotnet restore work just fine, but it's annoying to see these errors in VS Code.

I suspect the reason is some rudiment path value or an old .NET runtime. What I want to understand is what is the right way to debug and fix such a problem. The project is actually <TargetFramework>netcoreapp3.1</TargetFramework>. Changing it to <TargetFramework>netcoreapp2.0</TargetFramework> looks wrong and doesn't help.

Thank you in advance!

1
Report to the extension developers, github.com/OmniSharp/omnisharp-vscode/issuesLex Li

1 Answers

0
votes

I reported an issue to omnisharp-vscode and have got a swift response that solved my problem. The issue seems to be in Mono that was installed via brew. Two solutions were proposed:

  1. Install Mono from the official source https://www.mono-project.com/download/stable/
  2. Add a setting "omnisharp.useGlobalMono": "never",

I tried the second one and it solved the problem.

P.S. Thanks to @lex-li for the advice to create a bug on GitHub.