首页 > 解决方案 > Visual Studio Code C# 调试问题(终端进程无法启动:shell 可执行文件“dotnet”的路径不是符号链接的文件。)

问题描述

我使用创建了一个工作区dotnet new console,编写了一些代码。但是,当我尝试使用 Visual Studio 代码中的“运行/开始调试”选项开始调试它时,它会失败并显示以下消息:

执行任务:dotnet build /home/MY USERNAME/Desktop/Codes/C#/Console/Console.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary
终端进程启动失败:shell 可执行文件“dotnet”的路径不是文件的符号链接。
终端将被任务重用,按任意键关闭它。

在终端中使用该dotnet run命令可以正常工作,没有任何问题。但是由于某种原因,使用启动调试选项失败。我真的不想每次想启动程序时都输入这个命令。

这是dotnet --info命令的结果:

.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

我已经对结果进行了一些翻译,它可能与原始输出不完全匹配

标签: c#.netvisual-studio-code

解决方案


看来这个帖子是不会回复的。我找到了解决它的方法。在“tasks.json”文件中,我将命令“dotnet”替换为“/usr/bin/dotnet”,现在它工作正常。但我认为实际问题与路径变量有关,我的解决方案只是暂时的。


推荐阅读