首页 文章

VSCode调试测试 . 错误MSB1011:指定要使用的项目或解决方案文件,因为此文件夹包含多个项目或解决方案文件

提问于
浏览
0

在Visual Studio Code中,单击我的测试项目中的“debug test”代码镜头链接:

enter image description here

导致错误消息:

MSBUILD : error MSB1011: Specify which project or solution file to use
because this folder contains more than one project or solution file.

错误信息是有道理的,确实有几个项目可供选择但是 how do I point the debugger at the correct one?

我尝试更改我的构建任务在tasks.json中指向的.csproj文件,但它没有任何效果 . 一个快速谷歌出现了一般的VSCode文档进行调试,但我不知道如何为“调试测试”事件配置构建任务 .

2 回答

  • 0

    我相信你需要在vscode tasks.json和launch.json中设置测试项目和其他引用的层

  • 0

    您可以通过路径将项目或解决方案文件显式指定为构建args作为最后一个参数 .

    它可能是项目 .csproj 或解决方案 .sln 文件 .

    MSBuild.exe [开关] [ProjectFile]

    MSBuild cli reference

    示例tasks.json:

    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "msbuild",
            "args": [
                // Ask msbuild to generate full paths for file names.
                "/property:GenerateFullPaths=true",
                "/t:build",
                "solution_file.sln"
            ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "silent"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
    

相关问题