代码之家  ›  专栏  ›  技术社区  ›  Davide Icardi i3arnon

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

  •  2
  • Davide Icardi i3arnon  · 技术社区  · 8 年前

    我需要编译一个。NET解决方案,使用Visual Studio代码。 我的任务在里面 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构建 还是问题匹配者工作?

    1 回复  |  直到 6 年前
        1
  •  4
  •   Davide Icardi i3arnon    8 年前

    一个简单的解决办法是 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"
            }
        ]
    }
    
    推荐文章