Clear previous build log in VSCode

I posted an issue Building should clear the previous build log · Issue #1411 · platformio/platformio-vscode-ide · GitHub that the build log is not cleared when building a second time. The behavior not to clear the log is apparently a design choice, but the instructions to activate this don’t work: Redirecting...

Please click on “gear” icon near “Build” task in Menu > Tasks

There’s no menu named “tasks” in latest VSCode 1.40.2. If the instruction means the PlatformIO “project tasks” sidebar, there’s no gear icon there.

I managed to get the .vscode/tasks.json somehow anyway and pasted the code. No change when building.
Since I think this should be the default behavior, there should at least be a simple way to activate it. This was also addressed in VSCode; would like to clear terminal before build

This is the gear icon the documentation referred to… not the best, but it’s also a bit hard to describe since it’s a nested menu type option thingy.

platformio%20task%20configuration

It think the underlying issue is that custom tasks are broken again? Although I’m also probably doing something wrong as the VSCode tasks are like greek to me…

i.e.

{
    "version": "2.0.0",
    "tasks": [
         {
            "type": "PlatformIO",
            "task": "Build",
            "problemMatcher": [
                "$platformio"
            ],
            "group": "build",
            "presentation": {
                "panel": "new"
            }
        }
    ]
}

results in a toast saying that there are task errors, with this log output

Error: The PlatformIO task detection didn't contribute a task for the following configuration:
{
    "type": "PlatformIO",
    "task": "Build",
    "problemMatcher": [
        "$platformio"
    ],
    "group": "build"
}
The task will be ignored.

Thanks for the great demonstration how to open the tasks.json file! Much appreciated. I’ll clarify the text in the documentation.

Your code has a line that is missing from the documentation:

“group”: “build”,

Now I get a new terminal for each build, but also the error message you mentioned. (Actually, it’s the same with or without the “group: build” line.)

Even if we get this to work; is there a way to automatically close the old build terminal, or even better clear and reuse it?

1 Like

I notice there’s a PlatformIO setting platformio-ide.autoCloseSerialMonitor:

Automatically close cmd_device_monitor before uploading/testing,
default value is true.

A similar setting to close the old build log when building again would be great.
But fixing the script for just launching a new terminal would be a good start.

1 Like