我需要使用Visual Studio Code编译.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?
答案 0 :(得分:3)
一个简单的解决方案是让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"
}
]
}