简体   繁体   English

在Visual Studio Code中调试多个ASP.NET Core项目

[英]Debug multiple ASP.NET Core projects in Visual Studio Code

I have the following ASP.NET Core solution (solution.sln) structure in VS Code: 我在VS Code中具有以下ASP.NET Core解决方案(solution.sln)结构:

.vscode
  launch.json
  tasks.json
src/
  api/
    api.csproj
  web/
    web.csproj
test/
  api.test/
    api.test.csproj    
solution.sln

I need to debug both api.csproj and web.csproj so I added the launch.json: 我需要调试api.csproj和web.csproj,所以我添加了launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Api",
      "type": "coreclr",
      "request": "launch",
      "preLaunchTask": "build",
      "program": "${workspaceRoot}/src/api/bin/Debug/netcoreapp1.1/api.dll",
      "args": [],
      "cwd": "${workspaceRoot}/src/api",
      "stopAtEntry": false,
      "console": "internalConsole"
    },
    {
      "name": "Web",
      "type": "coreclr",
      "request": "launch",
      "preLaunchTask": "build",
      "program": "${workspaceRoot}/src/web/bin/Debug/netcoreapp1.1/Nupaya.Api.dll",
      "args": [],
      "cwd": "${workspaceRoot}/src/web",
      "stopAtEntry": false,
      "launchBrowser": {
        "enabled": true,
        "args": "${auto-detect-url}",
        "windows": {
          "command": "cmd.exe",
          "args": "/C start ${auto-detect-url}"
        },
        "osx": {
          "command": "open"
        },
        "linux": {
          "command": "xdg-open"
        }
      },
      "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "sourceFileMap": {
        "/Views": "${workspaceRoot}/src/api/views"
      }
    }
  ]
} 

And the following tasks.json: 以及以下task.json:

{
  "version": "0.1.0",
  "command": "dotnet",
  "isShellCommand": true,
  "args": [],
  "tasks": [
    {
      "taskName": "build",
      "args": ["Api", "Web"],
      "isBuildCommand": true,
      "showOutput": "always",
      "problemMatcher": "$msCompile"
    }
  ]
}  

But when I run it I get the following error: 但是当我运行它时,出现以下错误:

MSBUILD : error MSB1008: Only one project can be specified.

I have tried different options but I always end with some kind of error. 我尝试了不同的选择,但总是会遇到某种错误。

Does anyone knows what is the proper way to debug multiple ASP.NET CORE projects in Visual Studio Code? 有谁知道在Visual Studio Code中调试多个ASP.NET CORE项目的正确方法是什么?

Modify your tasks.json file to the following: 将您的tasks.json文件修改为以下内容:

{
  "version": "0.1.0",
  "command": "dotnet",
  "isShellCommand": true,
  "args": [],
  "options": {
    "cwd": "${workspaceRoot}"
  },
  "tasks": [
    {
      "taskName": "build",
      "args": [],
      "isBuildCommand": true,
      "showOutput": "always",
      "problemMatcher": "$msCompile"
    }
  ]
}

This should build your whole solution. 这应该构建您的整个解决方案。

To debug one of the project switch to Debug View, choose a configuration and then click Start Debugging button as shown on the screenshot below 要将项目之一调试为“调试视图”,请选择一种配置,然后单击“ Start Debugging按钮,如下面的屏幕截图所示。

vs代码中的调试

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio中测量ASP.NET Core项目中的代码覆盖率? - How to measure Code Coverage in ASP.NET Core projects in Visual Studio? 在调试中为SSL配置launchSettings.json - ASP.NET Core / Visual Studio Code - Configure launchSettings.json for SSL in debug - ASP.NET Core / Visual Studio Code Visual Studio-独立的Asp.net项目 - Visual studio - Separate asp.net projects 使用 Visual Studio 代码创建 Asp.net MVC 应用程序(非核心) - Create Asp.net MVC Application (not core) with visual studio code Visual Studio 2017 Docker支持不适用于ASP.Net Core Angular或React项目 - Visual Studio 2017 Docker support not available for ASP.Net Core Angular or React projects Mac上的Visual Studio进入调试模式而没有断点,ASP.NET Core提出了不寻常的建议 - Visual Studio on Mac enters debug mode without a breakpoint with an unusual recommendation for ASP.NET Core 如何使用Visual Studio代码将实体框架核心安装到asp.net核心3项目 - How to install entity framework core to asp.net core 3 project using visual studio code 如何从 asp.net 核心 5.0 中实体核心中的数据库更新 Visual Studio 代码中的模型 - How to update models in visual studio code from database in Entity Core in asp.net core 5.0 在Visual Studio 2017上添加asp.net项目时遇到问题 - Having trouble adding asp.net projects on Visual Studio 2017 使用Telosys DSL模型为asp.net core razor页面生成代码(多项目解决方案) - Using Telosys DSL model to generate code for asp.net core razor pages (solution with multiple projects)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM