Omnisharp can't start dotnet

Viewed 859

I am using VS Code and Unity.

Under the output tab (omnisharp log) I get this error

Starting OmniSharp server at 5/27/2022, 3:16:43 AM
    Target: /Users/<my.name>/unity/Test Project 3/Test Project 3.sln

[ERROR] Error: Command failed: dotnet --version
/bin/sh: dotnet: command not found

However, when I go the console, I can run dotnet --version just fine

dotnet --version
6.0.202

I now get the unity console telling me that the print command is invalid, but that error isn't highlighted in vs code.

Update: it seems to work if I open VS Code from the terminal. Doing research, it has something to do with the path. Still unsure why it doesn't normally work.

2 Answers

In your terminal enter: where dotnet

Set this directory for omnisharp.dotnetPath in your VSCode preferences.

.Net SDKs are available at this path in Program Files: C:\Program Files\dotnet\sdk
Do you have this .net SDK path set in your 'Environment Variables' -> 'System variables' -> 'Path'? If not, try that.

Related