首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >微服务实践之使用 Visual Studio 2022 调试Dapr 应用程序

微服务实践之使用 Visual Studio 2022 调试Dapr 应用程序

原创
作者头像
吴晓阳
修改2024-11-18 11:18:47
修改2024-11-18 11:18:47
1660
举报

安装配置相关软件

安装 PowerShell 7 / Core

代码语言:powershell
复制
dotnet tool install --global PowerShell

安装 Visual Studio 扩展 Microsoft Child Process Debugging Power Tool 2022

安装插件后启动 Visual Studio,可以在 Debug -> Other Debugging Targets 中找到 Child Process Debugging Settings。

这里save按钮要点,上面的保存按钮也要点

生成配置文件

代码语言:xml
复制
<?xml version="1.0" encoding="utf-8"?>
<ChildProcessDebuggingSettings IsEnabled="true" xmlns="http://schemas.microsoft.com/vstudio/ChildProcessDebuggingSettings/2014">
  <DefaultRule Attach="false" />
  <Rule IsEnabled="true" ProcessName="dapr.exe" CommandLine="" EngineFilter="{3b476d35-a401-11d2-aad4-00c04f990171}" />
  <Rule IsEnabled="true" ProcessName="dotnet.exe" CommandLine="" EngineFilter="{3b476d35-a401-11d2-aad4-00c04f990171}" />
  <Rule IsEnabled="true" ProcessName="front.exe" CommandLine="" EngineFilter="{2e36f1d4-b23c-435d-ab41-18e608940038}" />
  <Rule IsEnabled="false" ProcessName="pwsh.exe" CommandLine="" EngineFilter="{3b476d35-a401-11d2-aad4-00c04f990171}" />
</ChildProcessDebuggingSettings>

修改launchSettings.json

代码语言:json
复制
{
  "profiles": {
    "http": {
      "commandName": "Project",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": true,
      "applicationUrl": "http://localhost:5000"
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "launchUrl": "swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "Container (Dockerfile)": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
      "environmentVariables": {
        "ASPNETCORE_HTTP_PORTS": "8080"
      },
      "publishAllPorts": true
    },
    "Dapr-PWSH": {
      "commandName": "Executable",
      "executablePath": "pwsh",
      "commandLineArgs": "-Command \"dapr run --app-id front --app-port 5000 --app-protocol grpc --log-level debug -- dotnet run --no-build\"",
      "workingDirectory": ".",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "nativeDebugging": true,
      "dotnetRunMessages": "true",
      "applicationUrl": "http://localhost:5000;https://localhost:5001"
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:12247",
      "sslPort": 0
    }
  }
}

运行项目

切换到backend项目,运行下面命令,注意端口

代码语言:C#
复制
dapr run --app-id backend --app-port 5001 dotnet run

开始调试front项目

访问:http://localhost:5000/swagger/index.html

正常进入调试

相关源码下载

相关文章

作者

吴晓阳

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装配置相关软件
  • 运行项目
  • 相关源码下载
  • 相关文章
  • 作者
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档