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中文网

相关推荐
1-1=02 天前
C# IO和序列化
c#·.net·.netcore
宝桥南山3 天前
.NET 11 - 尝试一下Blazor中的新特性SupplyParameterFromTempData
microsoft·微软·c#·asp.net·.net·.netcore
1-1=04 天前
C# 特性(Attribute)
c#·.net·.netcore
淡海水5 天前
10-01-互操作-C#与C++边界的内存管理
unity·c#·游戏引擎·.netcore·gc
1-1=05 天前
C# 反射
c#·.net·.netcore
1-1=06 天前
C# 泛型
c#·.net·.netcore
淡海水8 天前
09-01-内存-Unity资源生命周期全景
unity·c#·游戏引擎·.netcore·gc
1-1=08 天前
.NET Core 编译技术
.net·.netcore
1-1=09 天前
.NET Core 文件系统
.net·.netcore·1024程序员节
1-1=010 天前
.NET Core 内存管理
.net·.netcore