The net core sdk cannot be located как исправить

Introduction

This page contains more information about the error:

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.

What this error means is that this extension ran the command dotnet and dotnet was NOT found on the PATH within the extension’s process.

If you don’t have the .NET Core SDK installed, fixing this error is usually simple enough: visit https://dot.net/core-sdk-vscode to download and install the .NET Core SDK.

If you do have the .NET Core SDK installed, then this means that the directory containing dotnet (Linux and macOS) or dotnet.exe (Windows) is not on your PATH, at least in this extension’s process. The rest of this page will provide advice on understanding why.

Known issues

Before we get to a list of troubleshooting steps, lets first enumerate a few known reasons why this error happens:

  1. If you very recently installed the .NET SDK —
    • If you had Visual Studio Code open at the time you installed the .NET SDK, and you haven’t restarted it, you should do so.
    • On Windows, on some machines, environment variable changes don’t immediately take effect. Restart your computer to see if that resolves this problem.
  2. If the .NET SDK was installed through Linux Snap — see Linux Snap instructions

General troubleshooting steps on Linux/Mac

The first step in troubleshooting this problem is to see if this problem also happens is a terminal/shell. After you have launched a terminal or shell, type in which dotnet.

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. Alternatively, you can attempt to debug VS Code to understand what is going wrong — at this time at least, the function to debug is getUnixShellEnvironment. Lastly, you could manually add a symbolic link from within a directory which is on the PATH in all processes to wherever dotnet is installed (see below for instructions).

If which dotnet produces no output, then this means the .NET SDK wasn’t able to modify the PATH or add a symbolic link, or the .NET SDK for your platform doesn’t do so. You can fix this by either adding a symbolic link yourself (example: sudo ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet where /usr/share/dotnet/dotnet should be replaced with wherever the .NET SDK installer for your platform was installed to), or by modifying your PATH manually (example: modify ~/.bashrc add add something like export PATH=$PATH:/new/directory/here).

General troubleshooting steps on Windows

First, as mentioned above, if you installed the .NET SDK since you last rebooted Windows, you might start by just rebooting to see if that fixes things.

Otherwise, you can start troubleshooting this problem is to see if this problem also happens is a command prompt:

  • Start a command prompt:
    • Hit WinKey+R to bring up the Windows run dialog
    • Type in cmd.exe
  • When the command prompt starts, type in where.exe dotnet.

If the result of running where.exe is that a path to dotnet.exe is printed (example: C:Program Filesdotnetdotnet.exe) then the .NET SDK has successfully added itself to the Windows Path. There are no known reasons why PATH wouldn’t be propagated to the VS Code process. You could try starting VS Code from the command prompt to see if that helps.

If the result of running where.exe is a message like INFO: Could not find files for the given pattern(s). then the .NET SDK wasn’t able to add itself to the PATH. You could try uninstalling and reinstalling the .NET SDK. You could also try examining the default path with the following steps:

  • Bring up System Properties:
    • Windows 10 — On the Start Menu, search for ‘This PC’ and bring up properties
    • Before — On the Start Menu, search for ‘My Computer’ and bring up properties
  • Go to the Advanced settings
  • Click the button for ‘Environment Variables’
  • Find ‘Path’ in either the user or system list
  • See if the dotnet.exe directory (example: C:Program Filesdotnet) is in the list. If not you could add it.
  • If it is in the list, you could see if maybe another directory has added it self incorrectly (example: added an opening quote without a trailing quote), or if the set of environment variables has grown very large — there is a limit of 32,767 total characters.

Note about 64-bit installs of the .NET SDK

In 64-bit environments the .NET SDK will fail to be discovered if the 32-bit dotnet path comes before the 64-bit dotnet path in the Environment PATH variable. Try removing the 32-bit path entirely from your PATH variable and relaunch VS Code to see if your issue is resolved.

Special instructions

Linux Snap instructions

The Linux Snap packages for the .NET Core SDK, by default, will not create the dotnet link. To do so, run sudo snap alias dotnet-sdk.dotnet dotnet. More information about this can be found in the .NET Core SDK release notes.

Note that, as of the time of this writing, there are also other incompatibilities between this extension and the .NET Core SDK Snap package beyond the dotnet PATH issue. This incompatibility may result in:

Some projects have trouble loading. Please review the output for more details.
It was not possible to find any installed .NET Core SDKs
Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from:
https://aka.ms/dotnet-download

More information about this problem can be found in dotnet/cli#12110.

Some community members have been successful in using the Snap install by following the instructions listed in Configuring Snap installs of dotnet-sdk.

Another possible workaround is to add the following to ~/.omnisharp/omnisharp.json.

{
    "MSBuild": {
        "UseLegacySdkResolver": true
    }
}

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.

I am setting up visual studio code for unity. I tried to install c# extension but the error

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

keeps popping up. All I want is to enable IntelliSense because its not working.

I already tried the ff:
reinstall the SDK after closing an open visual studio code
restart the computer
I also tried to make sure that C:Program Filedotnet is on the path under system variable

Randomize's user avatar

Randomize

8,56518 gold badges77 silver badges129 bronze badges

asked Aug 15, 2020 at 2:33

steve's user avatar

2

I’m following this tutorial — Share Azure Spatial Anchors
across sessions and devices — at Microsoft Docs.

It requires I open a project in VS,
but when I try to open it I get the following error:

error : The project file cannot be opened by the project system,
because it is missing some critical imports or the referenced SDK
cannot be found.

Detailed Information: Unable to locate the .NET Core SDK. Check that
it is installed and that the version specified in global.json (if any)
matches the installed version.

I have the SDK version specified in the JSON
and all the other tools specified in the tutorial, but still nada. 
I think I’m missing a step somewhere. Any help would be hugely appreciated.

Scott - Слава Україні's user avatar

asked May 1, 2019 at 17:02

muz's user avatar

0

Step 1) First run dotnet --list-sdks from the command line (as in Grzegorz Smulko’s answer). Take note of the greatest version number.

enter image description here

Step 2) Create a global.json file at the root of the solution with the exact version number from step 1. it needs to contain all the digits otherwise it wont work. This is the my version at the time of writing

{
  "sdk": {
    "version": "3.1.101"
  }
}

answered May 25, 2019 at 21:16

Max Carroll's user avatar

Max CarrollMax Carroll

1,1811 gold badge4 silver badges6 bronze badges

8

Try running dotnet --list-sdks in the console.
According to the info on the pages that appear after downloading .NET Core SDKs from https://dotnet.microsoft.com/download, you need to have version v2.2.106 for VS2017 and v2.2.203 for VS2019.

With only the v2.2.203 installed projects didn’t load for me in VS2019.
I had to install v2.2.105 too.

answered May 10, 2019 at 16:55

Grzegorz Smulko's user avatar

3

I fixed it by installing the x86 version of the SDK.

It looks like each version of Visual Studio has it’s own corresponding dotnet version that it builds on. This is due to msbuild requirements.

If you are a Visual Studio user, there are MSBuild version requirements so use only the .NET Core SDK supported for each Visual Studio version. If you use other development environments, we recommend using the latest SDK release.

https://github.com/dotnet/core/blob/master/release-notes/2.2/2.2.6/2.2.6.md

As detailed on that page, you’ll need the following versions of dotnet for each visual studio version:

  • Visual Studio 2017 (Windows): .NET Core SDK x86 2.2.108
  • Visual Studio 2019 version 16.0: .NET Core SDK x86 2.2.205
  • Visual Studio 2019 version 16.1: .NET Core SDK x86 2.2.301
  • Visual Studio 2019 version 16.2: .NET Core SDK x86 2.2.401

answered Jul 29, 2019 at 10:09

soniiic's user avatar

soniiicsoniiic

3462 silver badges5 bronze badges

4

I had this problem because I uninstalled some older dotnet SDKs. Not only would VS2019 no longer load dotnet core projects, but dotnet was no longer available on my path and so not available on the command line as simply dotnet.

After installing multiple older versions of dotnet and reparing my VS2019 install, I was finally able to fix it by adding C:Program Filesdotnet to my path. Then VS2019 would load the project again.

Also, none of this affected VS2017, which could load and fully work with the project. And it worked on the command line when I specified the full path to the dotnet executable.

answered Jul 9, 2019 at 18:25

Jason's user avatar

JasonJason

2512 silver badges3 bronze badges

3

None of the above worked for me. I noticed that I was having the issue on every type of project, even non-netcore. I was able to use the global.json and get that working. Then I noticed that I had a global.json in a directory further up which was referencing an alpha build of .net core. Deleted that file and bingo no further issue.

tl;dr

Make sure that there are no global.json files further up in your directory structure that are screwing things up.

Community's user avatar

answered Feb 11, 2020 at 20:50

WillT's user avatar

WillTWillT

2482 silver badges5 bronze badges

1

In my case, remove program files(x86)dotnet in Environment path then restart visual studio and it worked.

answered Feb 3, 2020 at 3:52

Hoang Tran's user avatar

Hoang TranHoang Tran

1611 silver badge4 bronze badges

2

I found the same issue. It was releated with this bug https://github.com/dotnet/core-setup/issues/4236

That seems to be a bug in dotnet x86 version.

I just changed x64 dotnet (C:Program Filesdotnet) to be before x86 dotnet (C:Program Files (x86)dotnet`) in the %PATH% environment variable and it worked just fine.

answered Aug 5, 2019 at 12:01

bruno.almeida's user avatar

3

I had the same error a while back which caused my web api projects to fail during the solution loading process.

I solved it by reinstalling the following items from https://dotnet.microsoft.com/download

  • .Net Core Runtime (2.2.401 was the latest at the time)
  • .Net Core SDk (2.2.6 was the latest at the time)

answered Aug 28, 2019 at 7:00

ian korkie's user avatar

I faced this problem in vs 2019 v16.3
I have uninstalled old versions of netcore 2.1 SDK except version 2.1.801.

I found a file global.json in the folder: c:Usersadmin (my login user is admin) that point to uninstalled version 2.1.602

Although netcore SDK version 2.1.801 is installed, it’s not used because it doesn’t match the Patch number.

from documentation:

The patch version is defined by the last two digits (yz) in the last portion of the number (xyz) for SDK versions 2.1.100 and higher. For example, if you specify 2.1.300 as the SDK version, SDK selection finds up to 2.1.399 but 2.1.400 isn’t considered a patch version for 2.1.300.

I modified the file to point to 2.1.801 and it’s working fine

answered Sep 25, 2019 at 17:28

M.Hassan's user avatar

I ran into this today, where a solution has some (but not all) the projects using .net core; I had not been into this project in probably a month and had not intentionally done anything with the .net SDKs, so this was a mystery what the heck happened.

My project has no global.json at the root, creating one with the the latest (3.1.201) from dotnet --list-sdks didn’t help. WTF?

Then I found this: https://developercommunity.visualstudio.com/content/problem/896868/unable-to-locate-the-net-core-sdk-after-1650-previ.html

Visual Studio now removes previous .NET Core SDKs. If you encounter this problem, you can:

– Install .NET Core SDK from https://dotnet.microsoft.com/download.

  • Don’t use global.json. The latest version of the .NET Core SDK is the default and can build apps targeting earlier versions of the .NET Core Runtime.

  • Include a roll forward indicator (in global.json) such as the following which will ensure running with any SDK higher than 3.1.100 [see link for details]

A routine install of the latest .NET sdk (3.1.300) resolved this issue, but this feels like really poor behavior of Visual Studio — if it can’t find an SDK, maybe tell us which one it’s looking for? Ugh.

answered May 28, 2020 at 15:07

Steve Friedl's user avatar

I was able to fix the VS 2019 issue with the below steps

  1. Run dotnet --list-sdks to know the exact version of the SDK installed
  2. Modify the global.json file in the root folder of the project (In my case it was showing 2.2.100 but I had 2.2.401 installed, I edited the same to point to that version and I was able to reload the projects

MMM's user avatar

MMM

2,6024 gold badges24 silver badges42 bronze badges

answered Mar 3, 2020 at 13:44

agnei's user avatar

agneiagnei

111 bronze badge

I tried everything listed in the answers with the same error in VS 2019 and ultimately the thing that wound up fixing it was following these steps:

Right-clicked on Solution and hit ‘Resolve Errors’

I spent a full day installing and uninstalling various .net packages and of all the things, that’s the one that got it to build.
…If Microsoft can tell where an error is, why doesn’t it just try to resolve it automatically?!

answered Jan 16, 2020 at 20:15

Erin B's user avatar

Erin BErin B

1217 bronze badges

answered Nov 12, 2020 at 14:30

druss's user avatar

drussdruss

1312 bronze badges

This can happen if you uninstall old versions of .NET Core SDK which all take a lot of space. What happens is the uninstaller removes the PATH entry of the dotnet executable, even the one by other .NET installations, so VS cannot find it. If that is the case, if you type in where dotnet in the terminal, you won’t get anything. Find the path to dotnet.exe manually (usually C:Program Filesdotnet) and add it to PATH. Check in Control Panel whether there is a version actually installed. Make sure to log off and log in again, otherwise it won’t work even if you restart VS.

Another possibility is that there is a mismatch between the versions. Type in dotnet --version in the terminal and check the default version. If you get a different version than expected, you can set the exact version you want used by VS by using the global.json file as instructed in other answers.

answered Dec 1, 2020 at 13:28

Gru's user avatar

Vscode configuration c# environment error The .NET Core SDK cannot be located.

English document address
But the method provided by this official document did not solve my problem. . . . . .
1,Introduction
What does the «The .NET Core SDK cannot be located error report» mean? It tells you that dotnet and dotnet was NOT found on the PATH, dotnet is not found on the path, although you have already added environment variables.
2,Known issues
Reason for error:
1. If VSCODE is opened while installing .NET SDK, try restarting VSCODE after installing .NET SDK
2. On some windows machines, environment variables will not take effect immediately, restart the computer
3,General troubleshooting steps on Windows
Open a DOS window and enter where.exe dotnet

If the installation path of dotnet.exe is displayed, it means that it has been successfully added to the window path. The official document indicates that it is not known why VSCODE does not recognize it, and an error The .NET Core SDK cannot be located will be reported.

If you finish typing the where.exe dotnet command, INFO: Could not find files for the given pattern(s) is displayed, indicating that the .NET SDK is not added to the path, please uninstall and reinstall the .NET SDK

Okay, let’s talk about how I solved it
download link

Both must be downloaded and installed,
The first is Microsoft Visual C++ 2015 Redistributable Update 3.

1. After opening, it looks like this, click Download

Second, check X64, click NEXT to select the path to install

The second is KB2533623
download link
One, it looks like this after opening, download

Second, you can also directly Baidu KB3071756, enter the download link, the downloaded file is like this

Third, after installing the above two, restart the computer, it is normal, and no more errors will be reported.

Понравилась статья? Поделить с друзьями:
  • У меня скорострел как исправить
  • Отсутствует файл msvcr110 dll что это за ошибка как исправить
  • Как исправить репутацию у нкр
  • Как найти системный администратор на виндовс
  • Как найти радиус 6 угольника правильного