Managing projects - I think I'm doing it wrong

I’m developing code for an ESP8266 (NodeMCU ESP-12E)

For the most part I think I’m getting the hang of using PlatformIO within VS Code. One part still escapes me. A couple days ago after working on one project in an unnamed workspace I created a new project, added some code and built and downloaded it. I was pleased to see it was performing well until I realized it was the behavior of the other project in the workspace. I could not figure out how to switch to the new project except by closing the workspace (which seems drastic) and reopening the new project.

Tonight I imported one example, built and ran it and it worked fine. Then I imported another example, built and ran. I wanted to build the first example but cannot see how to do that. (Except by closing the workspace and reopening the first project.)

I’m pretty sure I’m doing it wrong. I’ve been using VS Code for a while now but either doing it with scripting languages like Python and just running from a terminal or using cmake outside VS Code to build C/C++ executables. I’m probably not taking full advantage of VS Code.

My PlatformIO projects are generally not related. How should I be managing them so I don’t feel like I’m working at cross purposes with PlatformIO?


What I do is:

  • Create a new folder under my default home directory for my PlatformIO projects.
  • Cd into it.
  • Use commandline tools to initialise a new project – pio init -b uno for example.
  • Edit platformio.ini as required. Normally I write AVR C++ and not Arduino, so I remove the line framework=arduino.
  • Start up VSCode in the current folder – code . (the dot is required, at least on Linux.)
  • Create my source files in src and include as required.

To edit an existing project, I start VSCode and File->Open Folder, navigate to required folder and OK.

I don’t use workspaces. It sounds like you have an option in VSCode to “open last workspace” – I would disable that option. Likewise any “open last folder” options.

Workspaces simply allow you to, fir example, open a project folder but also to “pretend” that other files and/or folders exist in the same location. I don’t need that feature so don’t use it.



Thanks, I’ll try that.
I didn’t know I could disable workspaces so I’ll do that.
I recall changing to the target directory and executing “code .” and not getting the result I expected.

1 Like