1.環境 Windows,.NET Core 2.0,VS Code
dotnet> dotnet new console -o myApp
2.launch.json配置文件
{ // Use IntelliSense to find out which attributes exist for C# debugging // Use hover for the description of the existing attributes // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md "version": "0.2.0", "configurations": [ { "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. "program": "${workspaceFolder}/myApp/bin/Debug/netcoreapp2.0/myApp.dll", "args": [], "cwd": "${workspaceFolder}/myApp", // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window "console": "internalConsole", "stopAtEntry": false, "internalConsoleOptions": "openOnSessionStart" }, { "name": ".NET Core Attach", "type": "coreclr", "request": "attach", "processId": "${command:pickProcess}" } ,] }
在launch.json中
name:配置名稱,在啟動配置下拉菜單中顯示
type:配置類型
request:請求配置類型(一般為launch或attach)運行或附加
preLaunchTask:調試會話前要運行的任務
program:程序Build以后生成的dll,默認是${workspaceFolder}/bin/Debug/(target-framework)/(project-name.dll)
workspaceFolder:正在調試的程序的工作目錄的路徑。默認為當前工作區(即使用Code命令進入的目錄)
target-framework:框架
args:傳遞給程序的命令行參數
cwd:項目目錄
console:啟動調試目標的位置
stopAtEntry:調試器是否在目標的入口點停止,默認為 false
internalConsoleOptions:內部調試控制台的控制行為
processId:要附加到的進程 id。使用 "$ {command:pickProcess}" 以獲取要附加到的正在運行的進程的列表。如果使用 "processId", 則不應使用 "processName"。
注:在.NET Core 1.0版本中
externalConsole:Console單獨啟動配置,開發console時,如果需要輸入后調試,將值設置為true,將console單獨啟動即可。