99

When I open my vs code program I get this message:

The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.

If I installed and even uninstalled the .NET core SDK and reinstalled it, there were several ways to change the external terminal to Power Shell, but no changes. Another problem I have when I click on the terminal is this message: The terminal shell path "; C: \ Program Files \ dotnet" does not exist

If my .NET is on the same path and persists. Please tell me how can I fix my problem?

Visual studio code : version 1.42.1(x64) .NET core SDK : version 3.1.101(x64)

And I've tried these .NET core SDK versions: version 3.0.100(x64) , version 2.2.207(x64)

4
  • What do you mean by your .Net is on the same path? the same as some project? Commented Mar 16, 2020 at 21:54
  • 1
    That usually means you have apps with mixed bitness, such as VSCode x64 with .NET Core SDK x86. Commented Mar 17, 2020 at 1:12
  • I was running through the same problem. I just follow these steps from Shahriar Shovon and it worked out for me. linuxhint.com/install_dot_net_core_ubuntu Commented Mar 16, 2021 at 14:50
  • Solution for me: remove wrong entry in (system) environment variable PATH. See stackoverflow.com/questions/67413205/… Commented Nov 10, 2023 at 9:54

30 Answers 30

109

Note: - This solution works in Mac as well. I tried on Apple M3 (MacOS Sequoia)

  1. Just simply close your VS Code app. It seems the error is produced because you are installing .NET Core SDK when your VS Code is opened.
  2. After closing it, re-install the .NET Core SDK.
  3. You must be able to use it now.

It worked for me.

Link to download SDK: https://dotnet.microsoft.com/en-us/download

Sign up to request clarification or add additional context in comments.

5 Comments

This worked. Note that re-installing means "Uninstall and Install again" and not "Repair".
Worked for me in 22 Jan 2022. I just did simple Repair in appwiz.cpl and it worked. Note that after restarting VS code you still need to "Kill Terminal" and start "New Terminal". Otherwise u'll still get the same error. Crazy.
This also was my issue. Uninstall the C# extension. Shut everything down and reboot for luck. Open the .NET installer and choose Repair. Reinstall the C# extension. Success.
On Ubuntu, once you resolve this (these steps work), you might need to check permissions.
But why does this happen and what does reinstalling with vscode shut does different?
63

I have the 5.0.103 [/snap/dotnet-sdk/112/sdk] installed (as shown, using snap) on KDE neon (based on Ubuntu 20.04).

In order to inform vs code where to find the .Net sdk, set a symbolic link '/usr/local/bin'(this folder is normally in your path):
sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet

After that, restart Visual Studio Code.

This worked for me.

3 Comments

Another suggestion for Linux users would be to install .NET some other way than snap because of github.com/dotnet/core/issues/4446. For me installing with installation script (learn.microsoft.com/en-us/dotnet/core/tools/…) and manually adding symbolic link to /usr/local/bin resolved the error ln -s /home/USER/.dotnet/dotnet /usr/local/bin/dotnet
This also worked for me. Seems like a dumb issue when $DOTNET_ROOT is already set.
The above answer should have been accepted as the solution.
49

I'm on a MAC (High Sierra), and closing VSC and reinstalling SDK did not help in my case.

VSC kept saying that SDK was "not installed or not on the path". When I ran dotnet in the Terminal window I received "command not found" message.

I had to manually add /usr/local/share/dotnet to PATH in my ~/.bash_profile.

Correct path is displayed once SDK is installed (see picture below). I appended it to the PATH in my ~/.bash_profile, reopened Terminal, and it worked. You may have to reload VSC too.

Good luck!

enter image description here

5 Comments

This seem like the perfect solution to me and better than the accepted answer.
You don't need to uninstall and install again. Just followed this answer and the problem fixed.
This helped me get it fixed in Ubuntu. Differences being that in Ubuntu I installed the SDK using snap which puts it in /snap/dotnet-sdk/current. I made a change to ~/.profile to put that folder in my path.
In macOs Monterey with an M1, the correct path to add to my ~./bash_profile was: export PATH="/usr/local/share/dotnet/x64:$PATH" It finally worked for me. The other solutions didn't
In macOS Sonoma, I set the path like this one. export DOTNET_ROOT=/usr/local/share/dotnet export PATH=$PATH:$DOTNET_ROOT
28

DON'T DELETE ANYTHING BEFORE TRYING THIS!

To my fellow developers, I find a great and easy method!

1- Open VS Code and go to settings from the bottom left corner! enter image description here

2- Type in @ext:ms-dotnettools.csharp to search dotnet tools! enter image description here

3- Scroll down until you find "Omnisharp: Dotnet Path" and click Edit in settings.json link! enter image description here

4- Go to the end of the file and right before } symbol type in "omnisharp.dotnetPath": "YOUR_DOTNET_LOCATION" enter your dotnet path. note: don't forget to put a comma(,) before your line!

this will show vs code that you have a dotnet installed on your PC! enter image description here

5- We are not done yet! Last but not least go back to settings and find Omnisharp: Use Modern Net Check the box and close your VS code, after reopening you will see that your VS Code detects dotnet! enter image description here

Like this post if it worked out for you!!

One last thing! If your VS code detects it but still no snippets for C# you should check if you've set Omnisharp: Use Global Mono to always, if not then select always to enable it.

2 Comments

Great fix here. To find your VSCode path on Mac, run find / -name dotnet (typically it is /usr/local/share/dotnet/dotnet).
@fotijr thats correct! Thanks for mentioning, I don’t know if it does matter but I used my secret folder which is .dotnet, on mac if you use cmd + shift + . You will get to see hidden folders and I used my ‘Users/username/.dotnet’ path in it! I hope default dotnet path also works fine.
11

In my case it helped just to quit VSCode and re-open it (no need to re-install the .NET Core SDK) and the message you mentioned is gone.

1 Comment

This worked for me as well. I think the path doesn't get updated the first time you open VSCode after installed the .NET Core SDK, or something like that.
7

The problem on my side (using Linux and zsh) was that even after installing .NET and exporting the required paths in ~/.zshrc:

export PATH=$PATH:$HOME/.dotnet
export DOTNET_ROOT=$HOME/.dotnet

VS Code was still unable to find these exports.

So, I added the same exports to my ~/.bash_profile file, and voilà, it worked! It looks like sometimes VS Code cannot read the zsh configuration files and only reads the bash ones. This might be the case for you as well.

1 Comment

This was the solution for me, thanks! I'm running vscode from the .tar.gz and adding the PATH in my ~/.bashrc wasn't recognized, because vscode uses /bin/sh
4

Working on Mac M1. I was facing the same issue when I open the project in VSCode. This is how I resolved

Steps:

  1. I quit my VS Code
  2. I reinstalled dotnet SDK
  3. I restarted my project

Initially, when I installed sdk, my VSCode was open, might be that was causing the issue.

Comments

3

I have the same problem,but my problem was cause by duplicate installation.

My solution as below:

1、open cmd, check the info of dotnet, I found it was a old version of 6.0.3,but I am sure I have installed a newest version of 7.0

input

dotnet --info

here is the output message

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.NETCore.App 6.0.3 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.3 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App]

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

2、check the path of dotnet,I found there is two different path of dotnet

where dotnet

C:\Program Files (x86)\dotnet\dotnet.exe
C:\Program Files\dotnet\dotnet.exe

3、go to the path I found,it’s clear that "C:\Program Files\dotnet" is the correct path of dotnet

C:\Program Files (x86)\dotnet

C:\Program Files\dotnet

4、edit environment variable,delete or move down the wrong path

environment variable

5、restart VScode,this error will not display anymore

1 Comment

Indeed, the wrong entry in the (system) environment variable PATH was the root of this issue. Thanks! See also stackoverflow.com/questions/67413205/…
3

For those of you who are on macOS and on M1, and after they closed VS Code and re-installed it, still don't get rid of the error. Try this:

On VS Code, click "Open folder..." and open your user folder. For example my name is Bob and here is the path of my user folder: "Macintosh HD/Users/bob".

Once the user folder is opened, on the left browser panel of VS Code, open those hidden files:

.bash_profile

.zshrc

and at the end of those files, add this:

export PATH="/usr/local/share/dotnet:$PATH"

And save those 2 files.

Basically, it allows apps trying to find .NET SDK to find it in the folder "/usr/local/share/dotnet" which is the default installation folder on macOS Ventura 13.1 (and some previous versions I don't know lol).

To be honest, only one of these two files needs this new line but I'm to lazy to figure out which one.

Restart your Mac and it should work.

1 Comment

For those who use Macs the first sign of this error is a broken path. I knew that the moment I couldn't use the terminal to find out what version Dotnet is. Using Shift cmd and . will enable hidden files for those that need assistance with that. I appreciate you Kath.
3

In my case the issue was that it wasn't installed in WSL. I'm using WSL2 running Ubuntu. So to solve this I just follow these steps on Ubuntu 22.04:

sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

If you use other version or want to use dotnet 7.x, follow this howto by Microsoft

Comments

3

For Linux users, debian or Ubuntu or fedora if you have VS Code installed as a flatpak it won't work as the app is sandboxed and can't talk to others outside of it, if you try you'll see that even where you installed the .NET SDK will be missing when you check the files using CD. Long story short switch to APT or RPM packages and then add the .NET CLI path (Should be in /usr/bin or preferably /usr/share/dotnet for debian based distros) to extension settings path and then you're good to go.

EDIT:

To add this to your extension path add this to your settings.json for VSCode

"dotnetAcquisitionExtension.existingDotnetPath": [
        {
            "extensionId": "ms-dotnettools.csdevkit",
            "path": "/usr/local/share/dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.vscodeintellicode-csharp",
            "path": "/usr/local/share/dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.csharp",
            "path": "/usr/local/share/dotnet/dotnet"
        },
        {
            "extensionId": "ms-dotnettools.vscode-dotnet-runtime",
            "path": "/usr/local/share/dotnet/dotnet"
        }

Where this file is located in debian based distros is /home/[your user]/.config/Code/User/settings.json

and it will automatically use the .net sdk you have installed there.

Comments

1

My issue was I was using .Net version 5 on Apple silicon, when I tried .Net 6 the problem got solved.

Comments

1

Start VSCode from your terminal:

code pathToProject

For MacOS, Linux and Windows users alike.

From the Troubleshooting: 'The .NET Core SDK cannot be located.' errors wiki page in OmniSharp's VSCode repo:

If which dotnet produces a PATH, then the .NET SDK was able to successfully modify the PATH, but VS Code isn't picking it up. VS Code attempts to scrape the environment by launching the default shell under the covers. But this process can be fragile. You can attempt to work around this by starting VS Code from your Terminal.

Comments

1

You can try using homebrew

  1. Install homebrew https://brew.sh
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Close Visual Studio Code
  2. Run brew install --cask dotnet-sdk

If you will have error like this

Error: You have not agreed to the Xcode license. Please resolve this by running:
  sudo xcodebuild -license accept

Then

  1. Run sudo xcodebuild -license accept
  2. Repeat brew install --cask dotnet-sdk

1 Comment

It works for me in Mac M1. Thanks
1

quit VS code. quit attached program (unity, etc). open originally attached program. Open VS code (assets > open c# project).

1 Comment

it doesn't work. In my case it is unity that should come with its own sdk version
0

my solution to this issue is: 1-you must uninstall all of the services belong to Visual Studio(not Vs Code) 2-uninstall VS Code and folder "AppData\Local\Programs\Microsoft VS Code" 3-download new dotnet core SDK and install vs code I hope it's done for you

2 Comments

This sounds like a bit of a nuisance; anyone reading this should check the upvoted answer below first as it seems to work for quite a few people.
stackoverflow.com/a/62748238/5013141 This answer is working for people
0

I downloaded the Build tools for Visual Studios 2019 and that seemed to fix my issue on VS Code.

So go to this URL: https://visualstudio.microsoft.com/downloads/

All Downloads -> Tools for Visual Studio 2019 -> Build Tools for Visual Studio 2019

Then of course, download and run, then select "C++ Build tools" and ".NET desktop build tools" and install.

Worked for me, hopefully works for others too.

Comments

0

Basically my goal was to get dotnet commands working on terminal on VS code. For that I spent an hour or two trying to find a solution. I came across a command "dotnet new console", and If i can execute it in the terminal of VS code I can get it to work. But it doesn't because it couldn't identify what dotnet was in the first place. The dotnet commands only worked on my base/usual cmd that comes with windows OS. So what I did was open my file in windows explorer that gives the error, open terminal in the same folder the project file is in (basically the folder that just popped up), and ran the script ("dotnet new console") without the quotes or brackets. It worked and I could use dotnet commands in the terminal of VS Code.

I have shown some arrows indicating files that weren't there before I ran the command. These files were added after running dotnet new console

enter image description here

Comments

0

Changing System Environment Variable Path from C:\Program Files (x86)\dotnet to C:\Program Files\dotnet fixed the problem for me.

Comments

0

If you are on Mac M1, make sure the package is ARM64. You choose if you want x64 or ARM64 when you download at the page, https://dotnet.microsoft.com/en-us/download/dotnet

This worked for me.

I also added the path to my .bash_profile file

You can find the .bash_profile file in your finder once you allow the showcase of hidden files.

Comments

0

I was having the same issue and tried answers here but they didn't solve the issue.

Finally I solved this by opening the project folder from terminal with code . as dotnet says here

I am using Unity and was opening the project folder by double-clicking the C# file on Unity. That was the issue in my case.

Hope this helps :)

1 Comment

the answer is outdated - the page is moved and changed significantly
0

uninstalling and then

sudo snap install dotnet-sdk --classic --channel=7.0

worked for me.

Comments

0

it is not the way to solve this problem but you can do it to have your code run you can open a command on that directory C:\Program Files\dotnet then write this

dotnet run   

and your code will automatically run

Comments

0

If you are on MacOS and have tried the above (setting correct PATH environment variable), and it still doesn't work, please try upgrading your VSCode. Although no error message suggested that this could be the issue, for me it fixed the problem. I had an "old" install (1.71.0, about one year old), and when I upgraded to 1.83.1 it started working.

For upgrading VSCode on MacOS, you basically have to uninstall it (delete it in Applications folder) and install it again. The installer can be found here. Check this one-minute video with instructions for upgrading VSCode.

Comments

0

My problem was if you type dotnet run in the console it worked, but pressing debug wouldn't do anything. running this command

export MSBuildSDKsPath="/usr/share/dotnet/sdk/$(dotnet --version)/Sdks"

And then restarting vs code is what fixed it for me.

Comments

0

On Mac I had to set the Dotnet Acquisition Extension: Shared Existing Dotnet Path property in settings to /usr/local/share/dotnet/dotnet, which is the default install path.

enter image description here

Comments

-1

This for future:- hi Jeeva if you install again unity with vscode please read this

First install vscode extension https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp

If you got error like this "The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path" then install https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-6.0.300-windows-x64-installer

If vscode shows "The reference assemblies for .NETFramework,Version=v4.7.1 were not found" on output terminal then install developer pack https://dotnet.microsoft.com/en-us/download/dotnet-framework/net471 then try exit and open vs code if not work then restart

Comments

-2

If you absolutely cannot get .NET Core SDK installed so that Omnisharp can find it, try unchecking the checkbox next to "Show Omnisharp Log On Error" under Settings > Extensions > C# Configuration > [] Show Omnisharp Log On Error

Comments

-2

Uninstall Vs code completely, start the process of installation on finishing C# dev kit installation you will get an error stating that .NET SDK can not be found, just click install SDK on the provided button within the error section the download the VSIX File copy it and paste in the .dotnet folder in program files. Here is a reference https://www.youtube.com/watch?v=S4Rks1L03LI&list=PLdo4fOcmZ0oWUrumb503vY3v6O3u3P4rW&index=2

1 Comment

Thank you for your interest in contributing to the Stack Overflow community. This question already has quite a few answers—including one that has been extensively validated by the community. Are you certain your approach hasn’t been given previously? If so, it would be useful to explain how your approach is different, under what circumstances your approach might be preferred, and/or why you think the previous answers aren’t sufficient. Can you kindly edit your answer to offer an explanation?
-8
  • Click on the error that is shown on your VS Code
  • Get into Settings of the error
  • Download it and you are all set

As shown in the image

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.