[英]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
按钮,如下面的屏幕截图所示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.