3

I am starting my journey into learning DotNet, and doing a demo application found on MS website, here: https://learn.microsoft.com/en-us/learn/modules/create-razor-pages-aspnet-core/3-exercise-create-new-aspnetcore-app.

I am getting the following error when trying to run dotnet in VSCode:

The term 'dotnet' is not recognized as the name of a cmdlet, but it works from command line.

Some information:

  • When opening a command prompt in Windows 10 (Admin or non admin), or Windows PowerShell, dotnet --help is found and responds.
  • The path to dotnet is set correctly for both my own user and also for the system account (just to be sure).
  • The tools is set in my user path as follows: %USERPROFILE%\.dotnet\tools.
  • I tried PowerShell and Command Prompt both as Admin and regular user, to check if it is perhaps a user rights elevation issue that makes it fail in VSCode, but it is not. Both user types work outside VSCode.

As far as I can tell, everything is correct, and the answers here do not work for me: dotnet is not recognized as the name of a cmdlet

My output when I do dotnet --version from the command prompt or PowerShell is:

C:\Users\bobandalice>dotnet --info .NET SDK (reflecting any global.json): Version: 6.0.100 Commit: 9e8b04bbff Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.100\ Host (useful for support): Version: 6.0.0 Commit: 4822e3c3aa .NET SDKs installed: 6.0.100 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download 

When doing the same in VSCode, the output is this:

PS C:\Users\bobandalice\OneDrive\dotnetapps\RazorPagesPizza> dotnet --info dotnet : The term 'dotnet' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + dotnet --info + ~~~~~~ + CategoryInfo : ObjectNotFound: (dotnet:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 

Any ideas?

5
  • Q: Have you tried uninstalling/re-installing .Net Core/.Net 5.x - including Microsoft Visual C++ Redistributable (x86) - on your workstation? stackoverflow.com/a/42800519/421195 Commented Nov 11, 2021 at 0:43
  • Thanks for your comment. I have just tried that again, as well - still the same problem. I am using DotNet 6 though, not 5. Also - as I said, I can do everything I need to do from command line, but not from VSCode. This seems like the C# extension for VSCode that is having some config issue perhaps? Commented Nov 11, 2021 at 0:47
  • I love VSCode, and I use it daily. But for C# development, I generally prefer using MSVS (MSVS Pro or MSVS Express) instead. Q: Is that an option for you? Commented Nov 11, 2021 at 1:35
  • I can if I don't need an expensive license. I am not a DotNet developer, as you can see by the question. I am just learning for now. My biggest client is going to rewrite their enterprise system into DotNet in 3 years, and I need to be relevant by then. They will migrate away from CodeIgniter and PHP. I am starting to prepare only now. Commented Nov 11, 2021 at 10:04
  • I am installing MSVS Community 2022 now. Not going to address my question, but am open to test new things out. Commented Nov 11, 2021 at 10:31

1 Answer 1

1

I'm having same issue. I'm not sure if this is ideal but this is something I figured out that seems to work. In the File -> Settings -> Preferences -> Features -> Terminal, I changed my terminal to external from integrated and it fixed the problem. I may be switching to Visual Studio Community also, though.

change terminal to external

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

2 Comments

Thank you for your comment. Mine is already set to integrated, but I will change it to External and then to Powershell, because it does work in Powershell, so that could possibly solve it. I will let you know how it goes.
Thank you. Don't know if this is the best solution but it most certainly works. Thanks again.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.