1.安装C#插件
全名C# for Visual Studio Code,选择微软的
2. 安装C# Dev Kit插件
全名C# Dev Kit for Visual Studio Code,同样是选择微软的
3.安装Debugger for Unity
4.配置launch.json 文件
{"version": "0.2.0","configurations": [{"name": ".NET Core Launch (web)","type": "coreclr","request": "launch","preLaunchTask": "build","program": "${workspaceFolder}/bin/Debug/net6.0/C#.dll","args": [],"cwd": "${workspaceFolder}","stopAtEntry": false,"serverReadyAction": {"action": "openExternally","pattern": "\\bNow listening on:\\s+(https?://\\S+)"},"env": {"ASPNETCORE_ENVIRONMENT": "Development"},"sourceFileMap": {"/Views": "${workspaceFolder}/Views"}},{"name": ".NET Core Attach","type": "coreclr","request": "attach"}]
}
type属性:coreclr 为.net core类型
program属性:根据自己的.net core项目的bin文件路径,找到 {项目名}.dll 文件所在路径,配置到program属性中
注意事项:
1.插件的版本要相互适配,最好是保持在一个稳定版本,或者都保持在最新版本
2.※检查插件是否都处于able状态(博主C#插件安装的时候,是disable状态)插件不启动vscode不识别,无法加载type属性的coreclr,也加载不了launch.json的.NET Core Launch模板
3.确保用到的插件,其下所有的依赖插件都是可用状态
参考资料:
Configuring C# debugging
在 Visual Studio Code 中调试 C#_Vscode中文网
在 Visual Studio Code 中调试_Vscode中文网