VS代码:调试位于子文件夹中的.NET Core项目 [英] VS Code: debug project .NET Core project that resides in a subfolder

查看:112
本文介绍了VS代码:调试位于子文件夹中的.NET Core项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将.NET Core项目移动到解决方案中的子文件夹后,我不再能够使用VS Code对其进行调试。

After moving my .NET Core project into a subfolder in the solution I am no longer able to Debug it using VS Code.

如果我移动 tasks.json launch.json 进入项目文件夹并在其中打开VS Code,我可以进行调试,但是我希望能够在VS Code中打开整个解决方案。

If I move tasks.json and launch.json into the project folder and open VS Code there I am able to debug, but I would like to be able to open the entire solution in VS Code.

错误消息我得到的是这样的:

The error message I am getting is this:

MSBUILD:错误MSB1003:指定项目或解决方案文件。当前工作目录不包含项目或解决方案文件。

该错误似乎表明我的任务运行程序无法找到我的项目,所以我尝试将其添加到 tasks.json

The error seems to state that my task runner can no longer find my project, so I tried adding this to tasks.json:

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

    // My addition
    "options": {
        "cwd": "${workspaceRoot}/myProjectFolder"
    }
}

这样做可以启动任务,但随后出现以下错误:

Doing this I am able to start the task, but I then get the following error:

Exception thrown: 'System.IO.FileNotFoundException' in 
Microsoft.Extensions.Configuration.FileExtensions.dll

如何配置.NET Core调试器以能够运行驻留的项目

How do I configure the .NET Core debugger to be able to run a project that resides in a sub folder?

推荐答案

问题是您的 tasks.json ,则应在父目录中复制子文件夹 .vscode / tasks.json

The problem is your tasks.json, you should copy your subfolder .vscode/tasks.json in the parent directory.

创建 tasks.json 从父目录,它像您的任务一样生成 tasks.json 。 json 示例。

When you create your tasks.json from the parent directory, it make a tasks.json like as your tasks.json example.

但是如果您复制在子文件夹中创建的 tasks.json 应该是这样的:

But if you copy the tasks.json created in the subfolder It should be some like this:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/<change to your subfolder>/<your project>.csproj"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

所以有 .csproj 文件,它在错误中显示。

So there is the .csproj file, it say in the error.

这篇关于VS代码:调试位于子文件夹中的.NET Core项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆