Calling "PlatformIO: Build" task with multiple projects in workspace

Hi there,

I’m quite new at using the PlatformIO IDE and VS Code.

I am currently dealing with several projects designed for ESP-32. For convenience, I would like to have them in the same VS Code Window / Workspace. I added the root folder of both to the workspace as usual.
When I am switching between files of the two projects, PIO detects the correct environment related to the file I’m editing. It is updated in the “Project Task” pane and when I click on “Build” from this pane, the build command is launched in the correct folder and environment.
But when I launch the “PlatformIO: Build” task with shortcut or from the command palette, on whatever file the focus is, the same project is built. The only way to build the second one is to open the sidebar and manually click on “Build”.

I tried with a new workspace and 2 blank projects and I got the same behavior.
I feel very frustrated not to be able to use shortcuts.

Is it supposed to work like this?
Is it due to a configuration mistake from me?
Is there any way to get the desired behavior?
Is it due to limitations in the interactions between VS Code and PIO?

Thanks for answering to any of these questions!
matpy

1 Like

Is the behavior the same with the latest beta version? Seems like PlatformIO VSCode IDE ignores selected active folder · Issue #2320 · platformio/platformio-vscode-ide · GitHub.

Thanks for the answer!

I installed the beta version. Now the project detection based on the focused file is not working at all. Switching between environments requires some time, so I’m OK with this behavior. I’m often frenetically selecting 10 different files per seconds which might be the cause of this bug on the current release as the switching task is called multiple times in a short time.

What’s great in this beta is that once the environment is manually selected and shown in the status bar (nice new feature!), the Build task always looks correctly configured and builds the desired project.

I believe this post can be considered as resolved since the upcoming release is going to fix the problem.

Hm since the behavior still doesn’t seem bulletproof, can you write a short bug report in the linked topic as feedback, including the exact procedure needed to trigger the bug?

With the beta version, I cannot reproduce the bug as they removed the ability of changing environment with the file in focus.