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 ?
VSCode sees on the active opened file. For example, if your last opened file was from “arduino-blink”, this project will be used.
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?
If you have a bunch of project roots in your project workspace… like so (where each of those is a self-contained project) …
… 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.
Thank you. That helps a lot!
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.
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!
This definitely seems broken - or at the least non-obvious / non-intuitive. When I select/open a file (like say, main.cpp), seems to follow that the tool would assume/switch that I would want to build that project, not some other/previous one.
I can’t confirm that it is broken.
The Project Environment Switcher works perfectly.
I’m afraid you just have to get used to it.
its fine - i’ll use this ‘environment switcher’ - but that doesn’t make it a good user experience.
Yes, unfortunately that’s how it is.
In the past, the behavior you are looking for already existed.
But that has led to many problems.
That’s why it was removed and the Project Environment Switcher was introduced.
“thats just how it is” lol. "it has led to many problems… (that the dev team couldn’t figure out how to fix “thats too hard!”).
Ok fine - its clunky but its not the end of the world.
But I sure hope you aren’t the Product Owner for this thing…
Nope, I’m not.
I’m just a hobby programmer using VS-Code + PlatformIO for my ESP32’s.
I have found the following procedure for myself:
I have my projects in individual folders.
If I want to open a project, I click on it with the right mouse button and select “Open with Code” from the context menu.
This gives me a fresh VS Code window that only contains the current project.
I no longer work with VS Code Workspaces.
Not even with workspaces that contain several projects. This is all too confusing for me and always leads to problems.
I’m new to PlatformIO. I haven’t looked into Workspaces, per se. I have opened multiple projects in the IDE, just as I have done in PyCharm and other IDEs for many years.
I could not get the IDE to switch between project contexts. The Project Tasks menu shows only one project, even though I have several open in the IDE (in the file explorer).
The “Project Environment Switcher” does not seem to apply to my issue; it appears to switch between multiple environments/build targets defined in the platformio.ini in a single project. I’m trying to switch between projects in the file explorer.
While digging around, I found an applicable setting in the PlatformIO Plugin settings: Activate Project On Text Editor Change.
With this option enabled, the project context changes to the project containing the active tab (with a brief “configuring project” popup). This sounds to me like what the OP was looking for.