Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andremarcondesteixeira opened this issue Jan 29, 2020 · 16 comments

Comments

@andremarcondesteixeira
Copy link

@andremarcondesteixeira andremarcondesteixeira commented Jan 29, 2020

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
@andremarcondesteixeira

This comment has been minimized.

Copy link
Author

@andremarcondesteixeira andremarcondesteixeira commented Jan 29, 2020

forgot to add C# output. Here it goes

Installing C# dependencies...
Platform: win32, x86_64

Downloading package 'OmniSharp for Windows (.NET 4.6 / x64)' (32146 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Windows (.NET 4.6 / x64)'

Downloading package '.NET Core Debugger (Windows / x64)' (47489 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package '.NET Core Debugger (Windows / x64)'

Downloading package 'Razor Language Server (Windows / x64)' (50022 KB).................... Done!
Installing package 'Razor Language Server (Windows / x64)'

Finished

@JoeRobich

This comment has been minimized.

Copy link
Collaborator

@JoeRobich JoeRobich commented Jan 29, 2020

Hi @andremarcondesteixeira,
It's because you have 1: Visual Studio Community 2019 16.2.29306.81 installed, which doesn't support .NET Core 3.1
Please update it to latest version or uninstall completely.

@andremarcondesteixeira

This comment has been minimized.

Copy link
Author

@andremarcondesteixeira andremarcondesteixeira commented Jan 29, 2020

I don't get it. Shouldn't VS Code be separeted from Visual Studio?

@andremarcondesteixeira

This comment has been minimized.

Copy link
Author

@andremarcondesteixeira andremarcondesteixeira commented Jan 29, 2020

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

@andremarcondesteixeira andremarcondesteixeira changed the title Omnisharp/Intelisense thinks there are errors everywhere Omnisharp trying to use MSBuild for Visual Studio instead of MSBuild for VSCode itself Jan 29, 2020
@JoeRobich

This comment has been minimized.

Copy link
Collaborator

@JoeRobich JoeRobich commented Jan 29, 2020

Hi @andremarcondesteixeira ,

In order to support both Full Framework and .NET Core projects, we rely on the Full Framework MSBuild. We package a minimal MSBuild with OmniSharp (it is prohibitive to include a full MSBuild because of the size), but defer to a full installation when one is found on your machine, since it will have all build tasks and target files included. In this case it is just an unfortunate circumstance that the Full Framework MSBuild you have installed does not support the newer .NET Core SDK that you are using.

@andremarcondesteixeira

This comment has been minimized.

Copy link
Author

@andremarcondesteixeira andremarcondesteixeira commented Jan 30, 2020

Is there any way I can help with this?

@JoeRobich

This comment has been minimized.

Copy link
Collaborator

@JoeRobich JoeRobich commented Jan 30, 2020

@andremarcondesteixeira, The best solution is to either update your Visual Studio (lots of improvements since VS16.2) or you could install the latest Visual Studio Build Tools to get a version of MSBuild that supports .NET Core 3.1.

@symbiogenesis

This comment has been minimized.

Copy link

@symbiogenesis symbiogenesis commented Feb 4, 2020

Shouldn't there be a fallback to the VS Code version of MSBuild upon error? I have VS installed and user-mode VS Code installed, and do not have local admin rights. So I cannot update Visual Studio.

@JoeRobich

This comment has been minimized.

Copy link
Collaborator

@JoeRobich JoeRobich commented Feb 4, 2020

@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"
            }
        }
    }
}
@symbiogenesis

This comment has been minimized.

Copy link

@symbiogenesis symbiogenesis commented Feb 6, 2020

Would be great to have a boolean setting for this, so that I won't need to update the MSBuildPath on every upgrade.

@filipw

This comment has been minimized.

Copy link
Member

@filipw filipw commented Feb 7, 2020

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

We periodically raise the minimum version of VS that can be discovered and used. For example VS 2017 is never used anymore, even though it used to be.
The lowest one OmniSharp picks is VS 2019 16.0 but for .NET Core 3.x 16.3 is needed. It's a chicken and egg problem since OmniSharp picks MSBuild before knowing the framework (it needs MSBuild to recognize the framework). This was caused by the fact that .NET SDK team raised the minimum MSBuild version from 16.0 to 16.3 between the last RC of .NET Core 3 and the RTM version.

This "issue" will go away on its own once we raise the minimum VS 2019 version to 16.3 which I think we will do soon.
That said, while you are free to consider this being a "bug" I don't think it's a terrible assumption that if you want to do .NET Core 3.x development and VS2019 is on your machine, it would have been update to support .NET Core 3.x in the first place.

But as mentioned, it will resolve itself once we raise the minimum VS 2019 version.

Also, I will move this issue to the server repo as it belongs there.

@filipw filipw transferred this issue from OmniSharp/omnisharp-vscode Feb 7, 2020
@filipw filipw changed the title Omnisharp trying to use MSBuild for Visual Studio instead of MSBuild for VSCode itself Omnisharp tries to use MSBuild < 16.3 from Visual Studio 2019 in .NET Core 3.x projects Feb 7, 2020
@filipw

This comment has been minimized.

Copy link
Member

@filipw filipw commented Feb 10, 2020

@JoeRobich @david-driscoll @mholo65 should we just raise the min. VS to 16.3 and be done with this? it should help avoid a bunch of those .NET Core 3.x issues

// VS 2019 should be preferred
if (i.Version.Major >= 16)
score++;
else
score--;

@mholo65

This comment has been minimized.

Copy link
Member

@mholo65 mholo65 commented Feb 10, 2020

@filipw I'm ok with raising the min version to 16.3... Best would be if we could check what the target framework is and then set min version to 16.3 if project targets .NET Core 3.x. Problem is that we know the target framework after project have been processed by OmniSharp.MSBuild stuff, which needs MSBuild 😄 So it's really a chicken-egg situation.

@JoeRobich

This comment has been minimized.

Copy link
Collaborator

@JoeRobich JoeRobich commented Feb 12, 2020

@filipw I'm ok with the change. I think it is reasonable to expect late adopters to at least keep up with the last LTS release and 16.4 was an LTS release for us.

@filipw

This comment has been minimized.

Copy link
Member

@filipw filipw commented Feb 12, 2020

do you have maybe access to some telemetry on how installations of 16.x versions are distributed?
also, at the end of the day, these folks wouldn't be left in a broken state, they'd just move to the bundled msbuild like i.e. those who only have VS2017 installed

@JoeRobich

This comment has been minimized.

Copy link
Collaborator

@JoeRobich JoeRobich commented Feb 13, 2020

@filipw Of users who report telemetry, they are overwhelmingly using VS16.3+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.