Project creator (Visual Studio + env_default)

It’s not clear to me why:
platform init --ide visualstudio --board adafruit_grandcentral_m4

will create a project using as environment the one defined by env_default even if in platrform.ini is defined a section with
[env:adafruit_grandcentral_m4]
platform = atmelsam
board = adafruit_grandcentral_m4
framework = arduino

Not quite sure what you’re actually asking, and what the actual problem is there.

Do you mean why is the env_default (which I’m assuming you have since you haven’t given enough information about your platformio.ini file) environment being build when you do a ‘build’ , rather than the new one you just added? If so, it’s because env_default instructs which environment(s) are to be built by default, unless you specifically try to build those other environments.

i.e. running the platformio --init on a project with the default set correctly added the adafruilt_grandcentral_m4 environment.

Thanks for answer and sorry for incomplete info. Also forgive my English, it’s not my language

In my platformio.ini I have more than one env and also env_default. One of the predefined envs is grandcentral.
I also know that build will be executed for all env (or just the one specified by env_default) and I also know that I can force a different one using --environment but question is:
When I want to create a project for an ide (eg visualstudio) for a specified board (grand central) when inside platformio.ini there is env_default, it create the project using “defines” for such env and not for the required one.
The weird thing is that if grandcentral env is missing inside .ini, it is correctly created
in my platformio.ini default env is mega2560
executing ‘platform init --ide visualstudio --board adafruit_grandcentral_m4’ I will get:

  • a new env for grand central if this is missing inside the .ini
  • a platformio.vxproj file with inside defines for building mega2560
    I was expecting, inside project file, defines for building samd51 (and maybe a --environment as argument in platformio command line)

No worries… I will try to take it easy on you then! :wink:

I just realised you are using Visual Studio, not Visual Studio code… so can’t help re: platformio.vxproj

However, a quick test of platformio init makes me think the vxproj file that is created is for whatever board type you initialised last… ie. if you do nanoatmega328 and then adafruit_grandcentral_m4 it will have adafruit_grandcentral_m4 references. But if you do adafruit_grandcentral_m4 and then nanoatmega328 it will have nanoatmega328 references?

I do not think this has a connection to env_default - please correct me if I am wrong. Both boards are added to platformio.ini, but it seems that the platformio.vxproj gets completely replaced so only the last board type configured is present.

@ivankravets Is this a bug, or expected behaviour? Since init is supposed to"Initialize new PlatformIO based project or update existing with new data." Or am I missing something?

I’m sure that this is related to env_default.
executing “platform init --ide visualstudio --board adafruit_grandcentral_m4” when “env_default” is mega2560 it generated “defines” in project for “avr” even if --board says something different.
When “env_default” is adafruit_grandcentral_m4 it generated “defines” in project for “samd51” even if --board says something different.

Different discussion about overwritting .vxproj file, yes, It could add a new “platform” to the existing project

Should be fixed in the latest PlatformIO Core development version. Please re-test with

pio upgrade --dev

Yes it seems solved. Created a new project and defines are ok

1 Like