Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code C# Debugging Problem (The terminal process failed to launch: Path to shell executable "dotnet" is not a file of a symlink.)

I created a workspace using dotnet new console, wrote some code. But when I try to start debugging it using the option Run/Start debugging in visual studio code, it fails with the message:

Executing task: dotnet build /home/MY USERNAME/Desktop/Codes/C#/Console/Console.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
The terminal process failed to launch: Path to shell executable "dotnet" is not a file of a symlink.
Terminal will be reused by tasks, press any key to close it.

Using the dotnet run command in terminal works fine without any problems. But using the start debugging option fails for some reason. I really don't want to have to type this command every time I want to start the program.

Here is the result of dotnet --info command:

.NET Core SDK (reflects global.json if exists):\
 Version:   3.1.302\
 Commit:    41faccf259

Runtime Environment:\
 OS Name:     ubuntu\
 OS Version:  20.04\
 OS Platform: Linux\
 RID:         linux-x64\
 Base Path:   /usr/share/dotnet/sdk/3.1.302/

Host (useful for support):\
  Version: 3.1.6\
  Commit:  3acd9b0cd1

.NET Core SDKs installed:\
  3.1.302 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:\
  Microsoft.AspNetCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]\
  Microsoft.NETCore.App 3.1.6 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

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

I've done some translating with the result, it may not match entirely the original output

like image 257
BMoon Avatar asked Jul 25 '20 12:07

BMoon


People also ask

Can I use Visual Studio Code for C?

C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.

Is Visual Studio C free?

Visual Studio Community. A fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications and cloud services.

Why C is not running in VS code?

Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration. Find and check the box Run in Terminal.


3 Answers

Seems like this post isn't going to be answered. I've found a way to solve it. In "tasks.json" file i replaced the command "dotnet" with "/usr/bin/dotnet" and it's working fine now. But i think that the actual problem has something to do with the path variable and my solution is just a temporary one.

like image 191
BMoon Avatar answered Sep 19 '22 08:09

BMoon


try deleting the .vscode folder from the dotnet root project. Then restart the vscode project window this .vscode folder will regenerate automatically while you are asked to add configuration. And now your c# debugging should be working fine. It worked for me on Linux.

like image 25
Mohammad ABS Jabed Avatar answered Sep 21 '22 08:09

Mohammad ABS Jabed


This just randomly started happening on Mac for me. The fix was to add:

export dotnet=/usr/local/share/dotnet/dotnet

to my ~/.zshrc file. Then restart vscode.

like image 29
cscott530 Avatar answered Sep 17 '22 08:09

cscott530