dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 670 forks source link

Getting .NET Core SDK not located error when I open a script in VS Code in Unity3D. All solutions on Google only work for Windows and not Ubuntu 20.04 #4469

Open ghost opened 3 years ago

ghost commented 3 years ago

Environment data

dotnet --info output:

.NET SDK (reflecting any global.json):
 Version:   5.0.201
 Commit:    a09bd5c86c

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /snap/dotnet-sdk/116/sdk/5.0.201/

Host (useful for support):
  Version: 5.0.4
  Commit:  f27d337295

.NET SDKs installed:
  5.0.201 [/snap/dotnet-sdk/116/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.4 [/snap/dotnet-sdk/116/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.4 [/snap/dotnet-sdk/116/shared/Microsoft.NETCore.App]

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

VS Code version: 1.55.0 C# Extension version: v1.23.9

OmniSharp log

None

Steps to reproduce

Open a .cs file in Unity3D on Ubuntu 20.04

Expected behavior

No popup dialogue should appear at the bottom right

Actual behavior

A pop up dialogue appears at the bottom right reddit

That's the popup I get at the bottom right whenever I open a .cs script in VSCode inside Unity3D. It doesn't interfere with the code completion or the execution of the program but I can't understand why I am getting this error since I followed the steps here to install dotnet on Ubuntu 20.04. I also installed mono-complete by executing the following command in console:

sudo apt install mono-complete

But still VSCode inside Unity3D can't seem to locate dotnet SDK. I can confirm that dotnet SDK is installed on my system because whenever I check the version of dotnet SDK, I get the following:

muhammadmehdi@IITPAVISLW100:~$ dotnet --list-sdks
5.0.201 [/snap/dotnet-sdk/116/sdk]
muhammadmehdi@IITPAVISLW100:~$

And I also checked this inside the VSCode terminal:

muhammadmehdi@IITPAVISLW100:~/ellipsoid_visualization$ dotnet --list-sdks
5.0.201 [/snap/dotnet-sdk/116/sdk]
muhammadmehdi@IITPAVISLW100:~/ellipsoid_visualization$

So, it seems to be recognized inside the VSCode terminal but then why am I getting that popup message? I have also tried this but no luck.

I also added the following to my bashrc

export DOTNET_ROOT=/snap/dotnet-sdk/current

Still getting the same popup. Is VSCode looking for dotnet SDK some place else? If so, where is VSCode looking for it?

HarelM commented 3 years ago

I have the same issue. Just installed vs code on Ubuntu and I can't seems to be able to remove this warning. I even added the alias command as requested in the manual. I couldn't understand the help there - is it asking me to find the bug in vs code??? Also opening vs code from command line doesn't resolve this warning.

vzarytovskii commented 3 years ago

Hey folks, @iAmJuan550 @HarelM, could you please try following these instructions here and see if issue persists?

HarelM commented 3 years ago

Thanks for getting back to me. I'll try that later tonight and report back...

HarelM commented 3 years ago

@vzarytovskii the link and instructions on using a symbolic link did the trick, thanks!! I needed to use sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet since I didn't have permission to do it for some reason. I also recommend to change the following page to have this institutions instead of telling me I should debug some code I don't know where to find: https://github.com/OmniSharp/omnisharp-vscode/wiki/Troubleshooting:-'The-.NET-Core-SDK-cannot-be-located.'-errors That is linked when you click on help in vs code.

paulkre commented 3 years ago

On macOS this fixed it for me:

sudo ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/dotnet
LeFede commented 3 years ago

@iAmJuan550 hey! I've tried everything I can to make C# autocomplete work on my Ubuntu but it's been a huge mess. How did you manage to make it work? I'm not sure what I am doing wrong. I don't want to create a partition just to use Unity3D on Windows please help :(

JoeRobich commented 3 years ago

@LeFede Sorry you are running into an issue. Since your problem may not be the same as others, please open a new issue and provide the requested logs.

LeFede commented 3 years ago

@LeFede Sorry you are running into an issue. Since your problem may not be the same as others, please open a new issue and provide the requested logs.

I just did it. Thanks!

Link to issue