6

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.

7
  • 1
    Do you run your application and dotnet --version command(when it gives output) on the same machine? Maybe you run your application in the Docker container?
    – OlegI
    Commented May 27, 2022 at 9:31
  • Yes everything is on the same machine
    – Sean AH
    Commented May 27, 2022 at 9:32
  • I will ask if you are using an M1 Mac. Unless you have all binaries in ARM64, such errors are expected.
    – Lex Li
    Commented May 27, 2022 at 16:00
  • MacOS Montgomery 12.1 (21C52) - Macbook Air. I'm glad I found a workaround, but what if I hadn't? I just have to live with errors?
    – Sean AH
    Commented May 27, 2022 at 16:41
  • 1
    @SeanAH Try adding to your user settings file the two lines described here: stackoverflow.com/a/72385697/795016 Then make sure to fully close and reopen VSCode. his solved it for me!
    – Ben
    Commented Jun 4, 2022 at 12:22

2 Answers 2

3

In your terminal enter: where dotnet

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

Update: For the newer non-omnisharp version, set for dotnet.dotnetPath.

1
  • 2
    This worked for me. It suddenly stopped working today though. Not sure what I changed before this. Never had to update this before. Thanks for the tip, it helped!
    – radj
    Commented Aug 3, 2022 at 12:54
0

.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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.