VS Code $msCompile problemMatcher 不适用于相对文件路径

VS Code $msCompile problemMatcher doesn't work with relative file path

我需要使用 Visual Studio 代码编译 .NET 解决方案。 我在 tasks.json 中的任务声明如下:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "args": [
                "build",
                "${workspaceFolder}"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}

现在按 Ctrl+B 我可以成功编译我的整个解决方案。不幸的是 dotnet build 似乎输出相对文件路径,并且从 documentation 开始,$msCompile 问题匹配器仅适用于绝对路径。结果是,当在“问题”面板中单击它时出现错误会产生错误 Unable to open XYZ.cs: File not found.

如何正确配置 dotnet build 或 problemMatcher 才能工作?

一个简单的解决方案是让 dotnet build 使用 /property:GenerateFullPaths=true 参数生成绝对文件路径。 这是工作任务定义:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "args": [
                "build",
                "${workspaceFolder}",
                "/property:GenerateFullPaths=true"
            ],
            "problemMatcher": "$msCompile"
        }
    ]
}