vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

.NET 7 Preview 7 + VS Code = No Intellsense or analysis

Open JohnGalt1717 opened this issue 3 years ago • 3 comments

Issue Description

When using .NET Preview 7, Omnisharp correctly picks the preview sdk, but then errors with:

Failure while loading the analyzer reference 'Microsoft.CodeAnalysis.CSharp.CodeStyle': Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. VS.net works fine.

Steps to Reproduce

Install latest .net 7 preview 7. Create a console app: dotnet new console -o whatever Open in VScode Add some code.

Check the output logs for Omnisharp.

Expected Behavior

Should work as normal

Actual Behavior

No intellisense

Logs

OmniSharp log

Starting OmniSharp server at 9/9/2022, 2:05:14 PM Target: d:\Repos\pltfrmd\pltfrmd.sln

OmniSharp server started with .NET 7.0.100-preview.7.22377.5 . Path: c:\Users\jrlh.vscode\extensions\ms-dotnettools.csharp-1.25.0-win32-x64.omnisharp\1.39.0-net6.0\OmniSharp.dll PID: 49200

Starting OmniSharp on Windows 10.0.22621.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 4 MSBuild instance(s) 1: .NET Core SDK 7.0.100 17.4.0 - "C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5" 2: .NET Core SDK 6.0.400 17.3.0 - "C:\Program Files\dotnet\sdk\6.0.400" 3: .NET Core SDK 6.0.302 17.2.0 - "C:\Program Files\dotnet\sdk\6.0.302" 4: .NET Core SDK 6.0.301 17.2.0 - "C:\Program Files\dotnet\sdk\6.0.301" info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: .NET Core SDK 7.0.100 17.4.0 - "C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5" info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 info: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'd:\Repos\xxx\yyyy.sln'. ##Queue project updates### info: OmniSharp.Script.ScriptProjectSystem Did not find any CSX files info: OmniSharp.WorkspaceInitializer Configuration finished. info: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'd:\Repos\xxx' on host 47872. ###Loading, success, add for every project### info: OmniSharp.MSBuild.ProjectManager Update project: Auth info: OmniSharp.MSBuild.ProjectManager Update project: Contacts info: OmniSharp.MSBuild.ProjectManager Update project: Reports info: OmniSharp.MSBuild.ProjectManager Update project: Shared info: OmniSharp.MSBuild.ProjectManager Update project: Shared.Server info: OmniSharp.MSBuild.ProjectManager Update project: RavenDb.Repository info: OmniSharp.MSBuild.ProjectManager Update project: Data.RavenDb info: OmniSharp.MSBuild.ProjectManager Update project: Dtos info: OmniSharp.MSBuild.ProjectManager Update project: Localizations info: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Solution initialized -> queue all documents for code analysis. Initial document count: 174. [fail]: OmniSharp.MSBuild.ProjectManager Failure while loading the analyzer reference 'Microsoft.CodeAnalysis.CodeStyle': Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. [fail]: OmniSharp.MSBuild.ProjectManager

C# log

No logs, it never kicks it off.

Environment information

VSCode version: 1.71.0 C# Extension: 1.25.0

Dotnet Information .NET SDK: Version: 7.0.100-preview.7.22377.5 Commit: ba310d9309

Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.100-preview.7.22377.5\

Host: Version: 7.0.0-preview.7.22375.6 Architecture: x64 Commit: eecb028078

.NET SDKs installed: 6.0.301 [C:\Program Files\dotnet\sdk] 6.0.302 [C:\Program Files\dotnet\sdk] 6.0.400 [C:\Program Files\dotnet\sdk] 7.0.100-preview.7.22377.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0-preview.7.22376.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0-preview.7.22375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.0-preview.7.22377.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

Visual Studio Code Extensions
Extension Author Version
angular-essentials johnpapa 13.0.0
angular-schematics cyrilletuzi 5.2.6
Angular2 johnpapa 13.0.0
azure-account ms-vscode 0.11.1
azurecli ms-vscode 0.5.0
c-sharp-utilities revrenlove 1.4.0
csharp ms-dotnettools 1.25.0
docomment k--kato 0.1.31
dotnet formulahendry 0.0.4
dotnet-test-explorer formulahendry 0.7.7
EditorConfig EditorConfig 0.16.4
git-autoconfig shyykoserhiy 0.0.2
githistory donjayamanne 0.6.19
go golang 0.35.2
intellicode-api-usage-examples VisualStudioExptTeam 0.2.2
jupyter ms-toolsai 2022.8.1002431955
jupyter-keymap ms-toolsai 1.0.0
jupyter-renderers ms-toolsai 1.0.9
material-icon-theme PKief 4.20.0
msbuild-project-tools tintoy 0.4.9
ngrok-for-vscode philnash 1.10.0
prettier-vscode esbenp 9.8.0
python ms-python 2022.14.0
remote-containers ms-vscode-remote 0.251.0
remote-ssh ms-vscode-remote 0.84.0
remote-ssh-edit ms-vscode-remote 0.80.0
remote-wsl ms-vscode-remote 0.66.3
resxpress PrateekMahendrakar 4.8.0
se-csproj-extensions selcukermaya 0.0.7
user-secrets adrianwilczynski 2.0.1
visual-nuget fullstackspider 0.2.1
vscode-aks-tools ms-kubernetes-tools 1.3.4
vscode-docker ms-azuretools 1.22.1
vscode-edge-devtools ms-edgedevtools 2.1.1
vscode-eslint dbaeumer 2.2.6
vscode-firefox-debug firefox-devtools 2.9.8
vscode-kubernetes-tools ms-kubernetes-tools 1.3.10
vscode-npm-script eg2 0.3.28
vscode-pull-request-github GitHub 0.50.0
vscode-pylance ms-python 2022.9.10
vscode-resx-editor DominicVonk 0.0.5
vscode-versionlens pflannery 1.0.10
vscode-yaml redhat 1.10.1
vscodeintellicode VisualStudioExptTeam 1.2.25
vscodeintellicode-completions VisualStudioExptTeam 1.0.18
winteriscoming johnpapa 1.4.4
xml DotJoshJohnson 2.5.1

JohnGalt1717 avatar Sep 09 '22 21:09 JohnGalt1717

Same here. Any fix or help on troubleshooting is appreciated!

Logs

OmniSharp log

OmniSharp server started with .NET 7.0.100-rc.1.22431.12 . Path: c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.25.0-win32-x64\.omnisharp\1.39.0-net6.0\OmniSharp.dll PID: 8784

Starting OmniSharp on Windows 10.0.22000.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 1 MSBuild instance(s) 1: .NET Core SDK 7.0.100 17.4.0 - "C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12" info: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: .NET Core SDK 7.0.100 17.4.0 - "C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12" info: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 info: OmniSharp.MSBuild.ProjectSystem Skip loading projects listed in solution file or under target directory because MsBuild:LoadProjectsOnDemand is true. info: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in ''. info: OmniSharp.Script.ScriptProjectSystem Did not find any CSX files info: OmniSharp.WorkspaceInitializer Configuration finished. info: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location '' on host 21340. info: OmniSharp.MSBuild.ProjectManager Queue project update for '' info: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Solution initialized -> queue all documents for code analysis. Initial document count: 0. info: OmniSharp.MSBuild.ProjectManager Loading project: ... [fail]: OmniSharp.MSBuild.ProjectManager Failure while loading the analyzer reference 'Microsoft.CodeAnalysis.CodeStyle': Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. [fail]: OmniSharp.MSBuild.ProjectManager Failure while loading the analyzer reference 'Microsoft.CodeAnalysis.CSharp.CodeStyle': Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. [warn]: OmniSharp.Stdio.Host ************ Request ************ { "Type": "request", "Seq": 13069, "Command": "/v2/highlight", "Arguments": { "FileName": ".cs", "Line": 0, "Column": 0, "Range": { "Start": { "Line": 126, "Column": 0 }, "End": { "Line": 205, "Column": 62 } } } } [fail]: OmniSharp.Stdio.Host ************ Response (75743.3950ms) ************ { "Request_seq": 13069, "Command": "/v2/highlight", "Running": true, "Success": false, "Message": ""System.ArgumentException: An element with the same key but a different value already exists. Key: '(DocumentId, #03f8522f-9960-1f5f-38e3-d5f773547927 - JSExports.g.cs)'\r\n at System.Collections.Immutable.ImmutableSortedDictionary2.FillFromEmpty(IEnumerable1 items, Boolean overwriteOnCollision)\r\n at System.Collections.Immutable.ImmutableSortedDictionary2.AddRange(IEnumerable1 items, Boolean overwriteOnCollision, Boolean avoidToSortedMap)\r\n at System.Collections.Immutable.ImmutableSortedDictionary.ToImmutableSortedDictionary[TSource,TKey,TValue](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IComparer1 keyComparer)\r\n at Microsoft.CodeAnalysis.TextDocumentStates1..ctor(IEnumerable1 states)\r\n at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.FinalizeCompilationAsync(SolutionState solution, Compilation compilationWithoutGenerators, CompilationTrackerGeneratorInfo generatorInfo, Compilation compilationWithStaleGeneratedTrees, CancellationToken cancellationToken)\r\n at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.BuildCompilationInfoAsync(SolutionState solution, CancellationToken cancellationToken)\r\n at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetOrBuildCompilationInfoAsync(SolutionState solution, Boolean lockGate, CancellationToken cancellationToken)\r\n at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetCompilationSlowAsync(SolutionState solution, CancellationToken cancellationToken)\r\n at Microsoft.CodeAnalysis.Document.GetSemanticModelAsync(CancellationToken cancellationToken)\r\n at Microsoft.CodeAnalysis.Shared.Extensions.DocumentExtensions.GetRequiredSemanticModelAsync(Document document, CancellationToken cancellationToken)\r\n at Microsoft.CodeAnalysis.Classification.Classifier.GetClassifiedSpansAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)\r\n at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.Handle(SemanticHighlightRequest request) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn.CSharp\\Services\\SemanticHighlight\\SemanticHighlightService.cs:line 63\r\n at OmniSharp.Endpoint.EndpointHandler2.GetFirstNotEmptyResponseFromHandlers(ExportHandler2[] handlers, TRequest request) in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 201\r\n at OmniSharp.Endpoint.EndpointHandler2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 234\\r\\n at OmniSharp.Endpoint.EndpointHandler2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in D:\\a\\1\\s\\src\\OmniSharp.Host\\Endpoint\\EndpointHandler.cs:line 143\r\n at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in D:\\a\\1\\s\\src\\OmniSharp.Stdio\\Host.cs:line 258"", "Body": null, "Seq": 31811, "Type": "response" } [fail]: OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers Analysis of project (ProjectId, #39f9f8cb-e8be-40ee-a452-83b2a452f9a3 - .csproj) failed, underlaying error: System.ArgumentException: An element with the same key but a different value already exists. Key: '(DocumentId, #03f8522f-9960-1f5f-38e3-d5f773547927 - JSExports.g.cs)' at System.Collections.Immutable.ImmutableSortedDictionary2.FillFromEmpty(IEnumerable1 items, Boolean overwriteOnCollision) at System.Collections.Immutable.ImmutableSortedDictionary2.AddRange(IEnumerable1 items, Boolean overwriteOnCollision, Boolean avoidToSortedMap) at System.Collections.Immutable.ImmutableSortedDictionary.ToImmutableSortedDictionary[TSource,TKey,TValue](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IComparer1 keyComparer) at Microsoft.CodeAnalysis.TextDocumentStates1..ctor(IEnumerable1 states) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.FinalizeCompilationAsync(SolutionState solution, Compilation compilationWithoutGenerators, CompilationTrackerGeneratorInfo generatorInfo, Compilation compilationWithStaleGeneratedTrees, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.BuildCompilationInfoAsync(SolutionState solution, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetOrBuildCompilationInfoAsync(SolutionState solution, Boolean lockGate, CancellationToken cancellationToken) at Microsoft.CodeAnalysis.SolutionState.CompilationTracker.GetCompilationSlowAsync(SolutionState solution, CancellationToken cancellationToken) at OmniSharp.Roslyn.CSharp.Services.Diagnostics.CSharpDiagnosticWorkerWithAnalyzers.AnalyzeProject(Solution solution, IGrouping`2 documentsGroupedByProject, Action decrementRemaining) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Workers\Diagnostics\CSharpDiagnosticWorkerWithAnalyzers.cs:line 305

C# log

(no output)

Environment information

VSCode version: 1.72.0 C# Extension: 1.25.0

Dotnet Information .NET SDK: Version: 7.0.100-rc.1.22431.12 Commit: f1cf61e1c0

Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\

Host: Version: 7.0.0-rc.1.22426.10 Architecture: x64 Commit: 06aceb7015

.NET SDKs installed: 7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.25.0
gitlens eamodio 12.2.2
go golang 0.35.2
prettier-vscode esbenp 9.9.0
vscode-eslint dbaeumer 2.2.6

Qusic avatar Oct 09 '22 10:10 Qusic

This is because the current version of Omnisharp v1.25.0 has no support for Roslyn (Microsoft.CodeAnalysis) Version=4.4.0. It supports up to 4.3.0, if you look at the changelog for the 1.25.1-beta1 version here you will see this beta version supports Roslyn 4.4.0, so installing this beta version will fix your problem.

To install a beta version use this manual from the wiki.

Hope this helps.

rodyvansambeek avatar Oct 16 '22 15:10 rodyvansambeek

This also cause problem to browser-wasm project in dotnet 7.0 too. Hope this will got out of beta soon

Thaina avatar Oct 16 '22 18:10 Thaina

Try to uninstall the C# extension from VS code , close and open vs code and then install the extension again, it worked for me, it started working normally again

VinyJos avatar Nov 25 '22 05:11 VinyJos

Yes the latest version shipped with Roslyn 4.4.0

filipw avatar Nov 25 '22 07:11 filipw

I have the latest version of the C# extension, and versions 6.0.400, and 7.0.100 but VSCode doesn't work when I load a Net6.0 project, Why is that?

BritoAlv avatar Nov 26 '22 13:11 BritoAlv