dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 663 forks source link

VSCode c# extension not working due to not finding .NET. #4991

Open JonahFairweather opened 2 years ago

JonahFairweather commented 2 years ago

Environment data

dotnet --info output: .NET SDK (reflecting any global.json): Version: 6.0.101 Commit: ef49f6213a

Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: D:\Program Files\dotnet\sdk\6.0.101\

Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc

.NET SDKs installed: 6.0.101 [D:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.1 [D:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.1 [D:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.1 [D:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download VS Code version:1.63 C# Extension version: 1.23.17

OmniSharp log

Starting OmniSharp server at 1/2/2022, 2:21:49 AM Target: d:\Users\admin\Snowboarder

OmniSharp server started. Path: c:\Users\admin.vscode\extensions\ms-dotnettools.csharp-1.23.17.omnisharp\1.37.17\OmniSharp.exe PID: 3680

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    Using the 'dotnet' on the PATH.
    DotNetPath set to dotnet
    Located 2 MSBuild instance(s)
        1: Visual Studio Community 2022 17.0.32014.148 17.0.0 - "D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
        2: StandAlone 17.0.0 - "c:\Users\admin\.vscode\extensions\ms-dotnettools.csharp-1.23.17\.omnisharp\1.37.17\.msbuild\Current\Bin"
    Registered MSBuild instance: Visual Studio Community 2022 17.0.32014.148 17.0.0 - "D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin"
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Detecting Cake files in 'd:\Users\admin\Snowboarder'.
    Could not find any Cake files
    Detecting projects in 'd:\Users\admin\Snowboarder\Snowboarder.sln'.
    Queue project update for 'd:\Users\admin\Snowboarder\Assembly-CSharp.csproj'
    Detecting CSX files in 'd:\Users\admin\Snowboarder'.
    Could not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'd:\Users\admin\Snowboarder' on host 9748.
    Loading project: d:\Users\admin\Snowboarder\Assembly-CSharp.csproj
    The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
    Failed to load project file 'd:\Users\admin\Snowboarder\Assembly-CSharp.csproj'.

d:\Users\admin\Snowboarder\Assembly-CSharp.csproj D:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1217,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

    Attempted to update project that is not loaded: d:\Users\admin\Snowboarder\Assembly-CSharp.csproj
    No document found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs.
    No document found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs.
    Miscellaneous file: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs added to workspace

Received response for /quickinfo but could not find request. Received response for /quickinfo but could not find request.

    No document found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs.
    No document found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs.
    No document found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs.
    Miscellaneous file: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs added to workspace

Received response for /v2/blockstructure but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /v2/blockstructure but could not find request. Received response for /quickinfo but could not find request. Received response for /v2/getcodeactions but could not find request.

    Applying code action: Extract method
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 23, Column: 12.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 20, Column: 17.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 20, Column: 8.
    Applying code action: Introduce local for 'RespondToBoost()'

Received response for /v2/blockstructure but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 12, Column: 9.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 19, Column: 9.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 9, Column: 22.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 10, Column: 4.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 10, Column: 22.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 10, Column: 22.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 13, Column: 9.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 20, Column: 9.

Received response for /v2/getcodeactions but could not find request.

    ************ Request ************

{ "Type": "request", "Seq": 2437, "Command": "/filesChanged", "Arguments": [ { "FileName": "d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs", "changeType": "Change" } ] }

    ************  Response (85.1780ms) ************ 

{ "Request_seq": 2437, "Command": "/filesChanged", "Running": true, "Success": false, "Message": "\"System.IO.IOException: The process cannot access the file 'd:\\Users\\admin\\Snowboarder\\Assets\\Scripts\\PlayerController.cs' because it is being used by another process.\r\n at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)\r\n at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)\r\n at OmniSharp.Roslyn.BufferManager.d__8.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\BufferManager.cs:line 47\"", "Body": null, "Seq": 27889, "Type": "response" } Received response for /quickinfo but could not find request. Received response for /v2/blockstructure but could not find request. Received response for /completion/resolve but could not find request. Received response for /v2/getcodeactions but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 44, Column: 31.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 41, Column: 30.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 42, Column: 31.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 44, Column: 44.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 42, Column: 39.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 44, Column: 38.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 44, Column: 50.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 42, Column: 51.
    Miscellaneous file: d:\Users\admin\Snowboarder\Assets\Scripts\DustTrail.cs added to workspace

Received response for /v2/codestructure but could not find request. Received response for /v2/codestructure but could not find request. Received response for /v2/blockstructure but could not find request. Received response for /v2/getcodeactions but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\DustTrail.cs, Line: 12, Column: 37.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\DustTrail.cs, Line: 19, Column: 36.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 43, Column: 36.

Received response for /v2/getcodeactions but could not find request. Received response for /v2/blockstructure but could not find request.

    Miscellaneous file: d:\Users\admin\Snowboarder\Assets\Scripts\FinishLine.cs added to workspace
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\FinishLine.cs, Line: 12, Column: 44.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\FinishLine.cs, Line: 10, Column: 21.

Received response for /quickinfo but could not find request. Received response for /v2/blockstructure but could not find request.

    ************ Request ************

{ "Type": "request", "Seq": 6693, "Command": "/filesChanged", "Arguments": [ { "FileName": "d:\Users\admin\Snowboarder\Assets\Scripts\FinishLine.cs", "changeType": "Change" } ] }

    ************  Response (1222.0478ms) ************ 

{ "Request_seq": 6693, "Command": "/filesChanged", "Running": true, "Success": false, "Message": "\"System.IO.IOException: The process cannot access the file 'd:\\Users\\admin\\Snowboarder\\Assets\\Scripts\\FinishLine.cs' because it is being used by another process.\r\n at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)\r\n at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)\r\n at OmniSharp.Roslyn.BufferManager.d__8.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\BufferManager.cs:line 47\"", "Body": null, "Seq": 75982, "Type": "response" } Received response for /completion/resolve but could not find request. Received response for /completion/resolve but could not find request. Received response for /v2/getcodeactions but could not find request. Received response for /v2/blockstructure but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 29, Column: 11.

Received response for /completion/resolve but could not find request. Received response for /completion/resolve but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs, Line: 35, Column: 16.

Received response for /v2/getcodeactions but could not find request. Received response for /completion/resolve but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 8, Column: 27.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 12, Column: 9.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 6, Column: 13.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 11, Column: 32.
    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 23, Column: 9.
    ************ Request ************

{ "Type": "request", "Seq": 7947, "Command": "/filesChanged", "Arguments": [ { "FileName": "d:\Users\admin\Snowboarder\Assets\Scripts\PlayerController.cs", "changeType": "Change" } ] }

    ************  Response (4.3677ms) ************ 

{ "Request_seq": 7947, "Command": "/filesChanged", "Running": true, "Success": false, "Message": "\"System.IO.IOException: The process cannot access the file 'd:\\Users\\admin\\Snowboarder\\Assets\\Scripts\\PlayerController.cs' because it is being used by another process.\r\n at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)\r\n at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)\r\n at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize, Boolean checkHost)\r\n at System.IO.File.InternalReadAllText(String path, Encoding encoding, Boolean checkHost)\r\n at OmniSharp.Roslyn.BufferManager.d__8.MoveNext() in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\BufferManager.cs:line 47\"", "Body": null, "Seq": 83829, "Type": "response" } Received response for /v2/blockstructure but could not find request. Received response for /v2/blockstructure but could not find request. Received response for /completion/resolve but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 30, Column: 9.

Received response for /completion/resolve but could not find request. Received response for /v2/getcodeactions but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\CrashDetector.cs, Line: 19, Column: 28.

Received response for /completion/resolve but could not find request.

    No symbol found. File: d:\Users\admin\Snowboarder\Assets\Scripts\FinishLine.cs, Line: 14, Column: 45.

Steps to reproduce

Whenever I open a script in unity this message happens.

Expected behavior

The c# extension works properly.

Actual behavior

No c# extension benefits to be found on my side unfortunately.

Steps I have taken to try to fix this: Installed .NET 6.0 Installed .NET 4.7.1 developer pack Changed omnisharp.path to latest installed an earlier version regenerated the .cs and .sln files in the project Then yesterday I was advised to try installing Visual Studio, which I did but the problem persists.

Please help, thank you.

image

image

ath0rus commented 2 years ago

I too am having similar issues with omnisharp, vsc (both insiders and regular) and unity. I have both 5.0.400 and 6.0.101 installed

ghost commented 2 years ago

you need to mess a bit with Custom Analyzers to make it work fully, you need to download the nupkg file of Microsoft.Unity.Analyzers, open it with 7zip or winrar as a zip, and navigate to -> analyzers/dotnet/cs/ and add to Omnisharp as a custom analyzer the Dll that is in there. This should fix the problem, it did for me