Visual Studio Code生成任务给出“终端外壳路径“ dotnet”是目录”

时间:2019-09-24 03:00:53

标签: linux .net-core visual-studio-code debian

仅供参考,这是我第一次使用Visual Studio Code和Linux。但是我在Windows上使用Visual Studio 201x确实有很多背景。

我已经在Linux中安装了dotnet sdk,并将DOTNET_ROOT和PATH设置为$ HOME / dotnet。 当我在bash上运行dotnet命令时就很好了。
如果我在Visual Studio中运行终端并键入dotnet,它也可以正常运行。

但是,当我尝试触发构建和调试时,这将启动任务-构建:

> Executing task: dotnet build /usr/local/myPath/dotnet-docs-samples/appengine/flexible/HelloWorld/HelloWorld.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <

The terminal shell path "dotnet" is a directory

Terminal will be reused by tasks, press any key to close it.

从Visual Studio Code在终端中运行相同的命令也可以正常工作。只是没有构建任务(CTRL + SHIFT + B => Build)

是什么原因?我该如何解决?

1 个答案:

答案 0 :(得分:3)

打开文件“ .vscode / tasks.json”

在每个带有"command": "dotnet",的部分中,将"type": "process"替换为"type": "shell",

保存task.json,然后重试构建命令(CTRL + SHIFT + B)

更新

要在创建新项目时获得正确的类型,请进入C#扩展文件夹:

  • Windows: %USERPROFILE%.vscode \ extensions / ms-vscode.csharp-1.21.5 / dist

  • Linux / MacOs:〜/ .vscode / extensions / ms-vscode.csharp-1.21.5 / dist

编辑文件“ extension.js”并替换所有出现的

command:"dotnet",type:"process" by command:"dotnet",type:"shell"

但是每次C#扩展名更新后,您都必须这样做。