VS Code调试C#的两个问题:不能读取用户输入和exit code 1 错误

要调试,直接点击program.cs文件,OmniSharp会在编辑器中加载,并提示添加一些用来build和debug应用的配置,这些配置是会存放在.vscode文件夹中,包括:

  • launch.json
  • task.json

可以参考这两篇文章:

  • Instructions for setting up the .NET Core debugger
  • https://docs.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio-code

Debug模式下不能读取用户输入

在luanch.json中,控制台设置默认是”internalConsole”,即使用VS Code Debug Console。但是该配置并不能从控制台读取内容,比如应用中包含Console.ReadLine

根据官方文档,可以有两种解决办法:

  • “externalTerminal”:通过外部终端来运行进程。该方法在我这里能正常运行,虽然每次Debug时都是提示我
  • ”integratedTerminal”:通过VS Code内部的交互式终端。该方法在我这里不能成功运行,提示我launch: program ‘’ does not exist,即使添加了”internalConsoleOptions”: “neverOpen”也是一样。
    VS Code调试C#的两个问题:不能读取用户输入和exit code 1 错误_第1张图片

2 启用Debug模式时提示The preLaunchTask ‘build’ terminated with exit code 1

这个问题我目前没找到好的解决办法,这是单纯的勾选了记住我的选择。
参考过:

  • The preLaunchTask ‘build’ terminated with exit code 3221225506. #1340
  • Prelaunch task build terminated with exit code 1

我的VS Code环境:

  • Version: 1.44.0
  • Date: 2020-04-08T08:23:56.137Z
  • OS: Darwin x64 19.4.0

你可能感兴趣的:(C#)