Windows VSCode .NET CORE WebAPI Debug配置

1.安装C#插件

全名C# for Visual Studio Code,选择微软的

  1. 安装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中文网

相关推荐
weixin_379880923 天前
.Net Core WebApi集成Swagger
java·服务器·.netcore
The Future is mine5 天前
.Net Core 在Linux系统下创建服务
linux·运维·.netcore
*长铗归来*6 天前
ASP.NET Core Web API 中控制器操作的返回类型及Swagger
后端·c#·asp.net·.netcore
IDOlaoluo6 天前
VS2017 安装 .NET Core 2.2 SDK 教程(包括 dotnet-sdk-2.2.108-win-x64.exe 安装步骤)
.netcore
csdn_aspnet14 天前
使用 Entity Framework Code First 方法创建 ASP.NET Core 5.0 Web API
.netcore·webapi
小先生81214 天前
.NET Core项目中 Serilog日志文件配置
c#·.netcore
爱吃香蕉的阿豪14 天前
.NET Core 中 System.Text.Json 与 Newtonsoft.Json 深度对比:用法、性能与场景选型
数据库·json·.netcore
csdn_aspnet14 天前
ASP.NET Core 10.0 的主要变化
.netcore
csdn_aspnet17 天前
在 C# .NETCore 中使用 MongoDB(第 1 部分):驱动程序基础知识和插入文档
mongodb·.netcore
csdn_aspnet17 天前
在 C# .NETCore 中使用 MongoDB(第 3 部分):跳过、排序、限制和投影
mongodb·c#·.netcore