Error in omnisharp extension for vs code

Viewed 4071

I've been facing the next issue from quite a while now. I'm starting with asp.net core 2.0 and vs code. I have installed VS Code 1.17.2, dotnet sdk 2.0 and C# extension 1.13.0 by omnisharp. I created a mvc project runing dotnet new mvc. When I open vs code I'm getting a lot of error all over .cs files. enter image description here

I'm able of build and run the application without any issue.

enter image description here

Also IntelliSense and debugging works. When I see the errors tab I notice the next error among a lot others:

The type 'TargetFrameworkAttribute' exists in both 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

enter image description here

I'm guessing I have some problem with my environment but I can't figure out what is. Any idea is appreciated.

1 Answers

Looks to be a bug related to how Omnisharp uses the MSBuild from a local installation of Visual Studio 2017. If your VS installation is out of date, you may see this error.

The issue has supposedly been fixed in the 1.13.1 release of the Omnisharp extension for VS Code.

The ticket mentions that Visual Studio 2017 RTM was the culprit, but anecdotally, I was on 15.2 and had the same issue.

See bug ticket here for additional details: github.com/OmniSharp/omnisharp-vscode/issues/1855

Solutions from ticket:

  1. Update VS 2017 - this is generally worthwhile anyway as there have been 4 updates since RTM.
  2. Download and use a version of OmniSharp with the a fix that will cause OmniSharp not to use VS 2017 RTM. You can follow the instructions here to do that.
  3. Install the last release of C# for VS Code (1.12.1) and change the "extensions.autoUpdate" to false.
Related