Is there a problem matcher for running a dotnet application via VSCode?

536 Views Asked by At

I was hoping if someone has an idea on how I can utilise the tasks.json file in VSCode to capture the output of a dotnet run command.

Currently I have a launch item in my launch.json file to start a new chrome window for debugging angular apps. I have defined the preLaunchTask in that file to be one of the tasks below. There is another task but for brevity I've not included that here since I've resolved that using this documentation.

The aim is that once both the tasks complete, it will launch the Chrome window automatically for me. Currently, when I run the below task, will pick-up my C# project and run the console program. However, VSCode continues to think that that the task is still in progress therefore continues to wait in the hope that once that task completes, it can launch chrome. Obviously since it continues to think the task has not completed yet, it doesn't launch it.

What I've noticed is that when I amend the task below to be a dotnet build one (the autogenerated one by the C# for Visual Studio Code extension), it figures out that the task has successfully completed and launches chrome. Likely because I'm using the $msCompile problemMatcher pattern.

Getting to my question (bit long-winded sorry!)...

  • Is there a similar problemMatcher for running an application?
  • Would the below need to be amended by compounding a build task with this so it assumes a build has completed?

Grateful for any assist on this as I've Googled my afternoon away yesterday in trying to get to the bottom of this.

Thank you!

Code Samples

Dotnet Run Task

{
    "tasks": [
        {
            "label": "run",
            "command": "dotnet",
            "type": "process",
            "isBackground": true,
            "args": [
                "run",
                "--project",
                "${workspaceFolder}/XXX.csproj",
                "/property:GenerateFullPaths=true",
                "/consoleloggerparameters:NoSummary"
            ],
            "problemMatcher": {
                "pattern": "$msCompile"
            }
        }
    ]
}

Dotnet Build Task

{
    "label": "build",
    "command": "dotnet",
    "type": "process",
    "args": [
        "build",
        "${workspaceFolder}/XXX.csproj",
        "/property:GenerateFullPaths=true",
        "/consoleloggerparameters:NoSummary"
    ],
    "problemMatcher": "$msCompile"
}
0

There are 0 best solutions below