Solvedomnisharp roslyn Omnisharp tries to use MSBuild < 16.3 from Visual Studio 2019 in .NET Core 3.x projects

Issue Description

Starting a console project from scratch using the command line tools results in code that Intelisense thinks is wrong. There red lines everywhere, even though the code compiles and runs with no problem.

image

Steps to Reproduce

  1. Install dotnet core 3.1
  2. Install VSCode from scratch
  3. Install C# extension
  4. In the command line, enter an empty folder named 'teste' and type dotnet new console

Expected Behavior

No errors should be present

Actual Behavior

Intelisense show errors everywhere

Logs

OmniSharp log

Starting OmniSharp server at 29/01/2020 10:36:05
Target: d:\Documents\teste

OmniSharp server started.
Path: c:\Users\Andre.vscode\extensions\ms-vscode.csharp-1.21.9.omnisharp\1.34.9\OmniSharp.exe
PID: 7248

Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 2 MSBuild instance(s)
1: Visual Studio Community 2019 16.2.29306.81 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
2: StandAlone 16.3 - "c:\Users\Andre.vscode\extensions\ms-vscode.csharp-1.21.9.omnisharp\1.34.9.msbuild\Current\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: Visual Studio Community 2019 16.2.29306.81 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'd:\Documents\teste'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.MSBuild.ProjectSystem
No solution files found in 'd:\Documents\teste'
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\Documents\teste\teste.csproj'
info: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'd:\Documents\teste'.
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\Documents\teste\teste.csproj
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
info: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
info: OmniSharp.WorkspaceInitializer
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'd:\Documents\teste' on host 4164.
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\Documents\teste\teste.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Adding project 'd:\Documents\teste\teste.csproj'
info: OmniSharp.MSBuild.ProjectManager
Update project: teste
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
teste: Did not find 'Microsoft.NETCore.App' in lock file.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\Documents\teste\teste.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\Documents\teste\teste.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\Documents\teste\teste.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: teste
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
teste: Did not find 'Microsoft.NETCore.App' in lock file.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\Documents\teste\teste.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\Documents\teste\teste.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\Documents\teste\teste.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: teste
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
teste: Did not find 'Microsoft.NETCore.App' in lock file.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\Documents\teste\teste.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\Documents\teste\teste.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\Documents\teste\teste.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: teste
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
teste: Did not find 'Microsoft.NETCore.App' in lock file.
info: OmniSharp.MSBuild.ProjectManager
Queue project update for 'd:\Documents\teste\teste.csproj'
info: OmniSharp.MSBuild.ProjectManager
Loading project: d:\Documents\teste\teste.csproj
info: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'd:\Documents\teste\teste.csproj'.
info: OmniSharp.MSBuild.ProjectManager
Update project: teste
[warn]: OmniSharp.MSBuild.PackageDependencyChecker
teste: Did not find 'Microsoft.NETCore.App' in lock file.

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.41.1
C# Extension: 1.21.9

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.101 Commit: b377529961

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support):
Version: 3.1.1
Commit: a1388f194c

.NET Core SDKs installed:
2.1.801 [C:\Program Files\dotnet\sdk]
2.1.802 [C:\Program Files\dotnet\sdk]
3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-vscode 1.21.9
20 Answers

✔️Accepted Answer

@symbiogenesis You can force the use of the minimal MSBuild by creating a omnisharp.json file in your C:\Users{Your username}.omnisharp folder

omnisharp.json (update version numbers as appropriate)

{
    "MSBuild": {
        "msbuildoverride": {
            "MSBuildPath": "C:\\Users\\{your username}\\.vscode\\extensions\\ms-vscode.csharp-1.21.10\\.omnisharp\\1.34.10\\.msbuild\\Current\\Bin",
            "Name": "OmniSharp MSBuild",
            "PropertyOverrides": {
                "MSBuildExtensionsPath": "C:\\Users\\{your username}\\.vscode\\extensions\\ms-vscode.csharp-1.21.10\\.omnisharp\\1.34.10\\.msbuild"
            }
        }
    }
}

Other Answers:

I think it's a bug, because Omnisharp is trying to use the environment from another IDE. The extension is a VS Code extension, but is affected by Visual Studio not supporting dotnet core

More Issues: