vs代码的omnisharp扩展错误

Error in omnisharp extension for vs code

下一个问题我已经有一段时间了。 我从 asp.net 核心 2.0 和 vs 代码开始。我已经通过 omnisharp 安装了 VS Code 1.17.2、dotnet sdk 2.0 和 C# extension 1.13.0。 我创建了一个 mvc 项目 运行ing dotnet new mvc。当我打开 vs 代码时,我在 .cs 文件中遇到了很多错误。

我能够毫无问题地构建和 运行 应用程序。

IntelliSense 和调试也有效。 当我看到错误选项卡时,我注意到下一个错误以及其他错误:

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'

我猜我的环境有问题,但我不知道是什么问题。任何想法表示赞赏。

看起来是与 Omnisharp 如何使用本地安装的 Visual Studio 2017 中的 MSBuild 有关的错误。如果您的 VS 安装已过时,您可能会看到此错误。

据推测,此问题已在 VS Code 的 Omnisharp 扩展的 1.13.1 版本中得到解决。

票据提到 Visual Studio 2017 RTM 是罪魁祸首,但据传闻,我在 15.2 上遇到了同样的问题。

在此处查看错误票以了解更多详细信息:github.com/OmniSharp/omnisharp-vscode/issues/1855

工单中的解决方案:

  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.