dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.87k stars 676 forks source link

'System' not found after update to dotnet 6.0 #4930

Closed WebFreak001 closed 2 years ago

WebFreak001 commented 2 years ago

Issue Description

Same issue as #3290, but now with dotnet 6.0

Steps to Reproduce

Install dotnet 6.0, create a new console app through dotnet new console, open the project

Expected Behavior

Auto completion and everything should still work

Actual Behavior

All builtin types, System usings and even string literals get red squiggly lines under them, making the code unreadable. Autocompletion does not work properly.

grafik

The error on the first using line has error CS0246

Building and command line dotnet invocations still work fine.

Logs

OmniSharp log

``` Starting OmniSharp server at 7.12.2021, 11:48:59 Target: c:\Users\user\Documents\dev\ProjectName\ProjectName.sln OmniSharp server started. Path: c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.37.17\OmniSharp.exe PID: 17544 [info]: OmniSharp.Stdio.Host Starting OmniSharp on Windows 6.2.9200.0 (x64) [info]: OmniSharp.Services.DotNetCliService Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK [info]: OmniSharp.Services.DotNetCliService Using the 'dotnet' on the PATH. [info]: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 2 MSBuild instance(s) 1: Visual Studio Professional 2019 16.9.31129.286 16.9.0 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin" 2: StandAlone 17.0.0 - "c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.37.17\.msbuild\Current\Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: Visual Studio Professional 2019 16.9.31129.286 16.9.0 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin" [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0 [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.ImplementTypeWorkspaceOptionsProvider, Order: 110 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'c:\Users\user\Documents\dev\ProjectName'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'c:\Users\user\Documents\dev\ProjectName\ProjectName.sln'. [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\user\Documents\dev\ProjectName\Subproject1\Subproject1.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\user\Documents\dev\ProjectName\Dependency1\Dependency1.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\user\Documents\dev\ProjectName\Subproject2\Subproject2.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\user\Documents\dev\ProjectName\Subproject3\Subproject3.csproj' [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'c:\Users\user\Documents\dev\ProjectName\Subproject4\Subproject4.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'c:\Users\user\Documents\dev\ProjectName'. [info]: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer Configuration finished. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'c:\Users\user\Documents\dev\ProjectName' on host 16408. [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\user\Documents\dev\ProjectName\Subproject1\Subproject1.csproj [info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService Could not find document for file c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs [info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService Could not find document for file c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs [info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService Could not find document for file c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\user\Documents\dev\ProjectName\Subproject1\Subproject1.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\user\Documents\dev\ProjectName\Subproject1\Subproject1.csproj' [info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService Could not find document for file c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\user\Documents\dev\ProjectName\Dependency1\Dependency1.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\user\Documents\dev\ProjectName\Dependency1\Dependency1.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\user\Documents\dev\ProjectName\Dependency1\Dependency1.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\user\Documents\dev\ProjectName\Subproject2\Subproject2.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\user\Documents\dev\ProjectName\Subproject2\Subproject2.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\user\Documents\dev\ProjectName\Subproject2\Subproject2.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\user\Documents\dev\ProjectName\Subproject3\Subproject3.csproj [info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService Could not find document for file c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\user\Documents\dev\ProjectName\Subproject3\Subproject3.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\user\Documents\dev\ProjectName\Subproject3\Subproject3.csproj' [info]: OmniSharp.MSBuild.ProjectManager Loading project: c:\Users\user\Documents\dev\ProjectName\Subproject4\Subproject4.csproj [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'c:\Users\user\Documents\dev\ProjectName\Subproject4\Subproject4.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'c:\Users\user\Documents\dev\ProjectName\Subproject4\Subproject4.csproj' [info]: OmniSharp.MSBuild.ProjectManager Update project: Subproject1 [info]: OmniSharp.MSBuild.ProjectManager Update project: Dependency1 [info]: OmniSharp.MSBuild.ProjectManager Update project: Subproject2 [info]: OmniSharp.MSBuild.ProjectManager Update project: Subproject3 [info]: OmniSharp.MSBuild.ProjectManager Update project: Subproject4 [info]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Solution initialized -> queue all documents for code analysis. Initial document count: 43. Received response for /v2/gotodefinition but could not find request. [warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService No symbol found. File: c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs, Line: 10, Column: 13. Received response for /v2/getcodeactions but could not find request. Received response for /v2/getcodeactions but could not find request. [warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService No symbol found. File: c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs, Line: 12, Column: 0. [warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService No symbol found. File: c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs, Line: 8, Column: 9. Received response for /v2/gotodefinition but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /quickinfo but could not find request. Received response for /v2/getcodeactions but could not find request. [warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService No symbol found. File: c:\Users\user\Documents\dev\ProjectName\Subproject2\Program.cs, Line: 94, Column: 9. Received response for /v2/getcodeactions but could not find request. [warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService No symbol found. File: c:\Users\user\Documents\dev\ProjectName\Subproject4\SomeInterface.cs, Line: 0, Column: 10. ```

C# log

none

Environment information

VSCode version: 1.62.3 C# Extension: 1.23.17

Dotnet Information .NET SDK (gem�� "global.json"): Version: 6.0.100 Commit: 9e8b04bbff Laufzeitumgebung: OS Name: Windows OS Version: 10.0.19043 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100\ Host (useful for support): Version: 6.0.0 Commit: 4822e3c3aa .NET SDKs installed: 3.1.101 [C:\Program Files\dotnet\sdk] 3.1.402 [C:\Program Files\dotnet\sdk] 5.0.201 [C:\Program Files\dotnet\sdk] 6.0.100 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.13 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |arm|dan-c-underwood|1.5.2| |blamer-vs|beaugust|0.5.2| |code-d|webfreak|0.23.2| |cpptools|ms-vscode|1.7.1| |csharp|ms-dotnettools|1.23.17| |cursor-align|yo1dog|1.1.0| |cursorCharCode|zeithaste|0.2.0| |debug|webfreak|0.25.1| |docomment|k--kato|0.1.30| |gitlens|eamodio|11.7.0| |hex-fmt|keroc|1.0.0| |hex-hover-converter|maziac|1.2.1| |jupyter|ms-toolsai|2021.10.1101450599| |jupyter-keymap|ms-toolsai|1.0.0| |jupyter-renderers|ms-toolsai|1.0.4| |linkerscript|ZixuanWang|1.0.2| |materialdesignicons-intellisense|lukas-tr|4.0.0| |matlab|Gimly81|2.2.1| |nsis|idleberg|3.45.0| |palette-support|dqisme|1.0.0| |plantuml|jebbs|2.16.1| |python|ms-python|2021.11.1422169775| |reg|ionutvmi|1.0.3| |remote-wsl|ms-vscode-remote|0.58.5| |roslynator|josefpihrt-vscode|3.3.0| |sqltools|mtxr|0.23.0| |sqltools-driver-mysql|mtxr|0.2.0| |svn-scm|johnstoncode|2.15.0| |synthwave-vscode|RobbOwen|0.1.10| |test-adapter-converter|ms-vscode|0.1.4| |vscode-css-peek|pranaygp|4.2.0| |vscode-hexdump|slevesque|1.8.1| |vscode-jsp|pthorsson|0.0.3| |vscode-lldb|vadimcn|1.6.10| |vscode-nxunit-test-adapter|wghats|0.1.3| |vscode-proto3|zxh404|0.5.5| |vscode-pylance|ms-python|2021.12.0| |vscode-test-explorer|hbenl|2.21.1| |vscode-text-pastry|jkjustjoshing|1.3.1| |vt100-syntax-highlighting|Tobias-Faller|1.0.1| |xml|DotJoshJohnson|2.5.1|;

I tried deleting ~/.vscode/extensions/ms-dotnettools.csharp-1.23.17 and reinstalling as suggested in https://github.com/OmniSharp/omnisharp-vscode/issues/2147#issuecomment-378289443 but it didn't fix it

WebFreak001 commented 2 years ago

updating Visual Studio (not vscode) has fixed this for some reason.

I don't know what Omnisharp has to do with VS but seems like that fixed it.

filipw commented 2 years ago

OmniSharp tries to use MSBuild from Visual Studio if Visual Studio is installed on your machine.

It was visible in your logs as:

Registered MSBuild instance: Visual Studio Professional 2019 16.9.31129.286 16.9.0 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin"