I ran into a problem today where I was seeing warnings regarding NuGet packages with reported vulnerabilities, but was not seeing the output under the 'Problems' tab in VSCode. In an effort to fully move away from Visual Studio (because it's slow, and because investing skills in a single 'do everything' editor seems more efficient to me) I'm trying to fix as many bugbears as I can in my VSCode configuration.
The key property is the "problemMatcher" property in the full tasks.json below. Here you can add a custom property with a regular expression that you define to pick up the warnings from the build output.
Hopefully if you're reading this this solves the same problem for you.
{
"version": "2.0.0",
"tasks": [
{
"label": "clean",
"command": "dotnet",
"type": "process",
"args": [
"clean",
"${workspaceFolder}/src/Example.sln"
],
"problemMatcher": "$msCompile"
},
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/src/Example.sln",
"/maxcpucount", // Enable multi-core parallel builds
"/nodeReuse:true", // MSBuild keeps worker nodes alive between project builds
"/p:BuildInParallel=true" // Enable parallel project builds
],
"problemMatcher": [
"$msCompile",
{
"owner": "nuget",
"pattern": {
"regexp": "^(.*)\\s*:\\s*(warning|error)\\s+(NU\\d+):\\s+(.*)$",
"file": 1,
"severity": 2,
"code": 3,
"message": 4
}
}
],
"group": {
"kind": "build",
"isDefault": true // Makes this the default build task (Ctrl+Shift+B)
}
}
]
}