PlatformIO&VSCode: How to select the project to be build

Look at these two projects below, but I don’t know how to select the “arduino-blink” project in order to build and upload it. Every time I build, whatever I do, it builds always the first project. So this is my question, how to select a project to be the main project ?

image

1 Like

VSCode sees on the active opened file. For example, if your last opened file was from “arduino-blink”, this project will be used.

1 Like

So there is no option in configuration file to select the project to run except closing the other project, isn’t it ?

Do you mean Redirecting... ?

That link doesn’t really address the OP’s question. At least, as a newcomer to Platform IO, I could not figure out how to choose which project to compile in a multiproject workspace. Does one need to create a new Task?

2 Likes

If you have a bunch of project roots in your project workspace… like so (where each of those is a self-contained project) …

image

… all you need to do is expand (click on) the one you want to work on/build, and open the main source file (or any file in that project, really, even the platformio.ini) … and it will become the active project, so that when you hit build down the bottom, or hit the platformio alien head in the sidebar, the options will be for that project. If you have files from multiple projects open, the ‘active’ project will follow which tab you have open.

Basically, the currently open tab determines the active project to be build / uploaded / etc.

2 Likes

Thank you. That helps a lot!

1 Like

Long time later, I know… But I stumbled upon the same issue. Following your guideline is NOT solving it. PlatformIO keeps on using the first project in the workspace, despite expanding or collapsing all the others…

The only way out I see for the moment is to close the workspace (or folder, if you have only one folder open) and then select to open an existing project in PlatformIO and select the one you’re interested in.

Anything I’m missing?

There has been a big change in the behaviour of PlatformIO on VSCode since this particular issue arose.

Now, if you want to choose the board/workspace to be compiled by default if you use the status bar/keyboard shortcut build/upload/etcoption, there is a entry you click on in the status bar, which will then prompt for which project / board to work with by default.

10 Likes

Indeed, that’s solving my issue. Thanks for pointing this out.

I almost didnt leave PIO because could not figureout why other project uploading everytime. Thank you very much!