Teensy's usbMIDI, Serial Port and Programmer Button

Hi

when I worked with Teensyduino, I had to switch the SerialPort to “MIDI” first, before build and upload.

now I am trying out platformio for visualCode , which is really nice, but I can’t get it how it works here(?)

I have a very simple code:
#include <Arduino.h>
void setup() {
}
void loop() {
usbMIDI.sendRealTime(usbMIDI.Clock);
usbMIDI.send_now();
delay(20);
}

I have added to platformio.ini:
build_flags = -D USB_MIDI

and the first time it uploads and in hairless-midi i can see signals comig out of the teensy.

then I change, lets say the delaytime to whatever, upload again… and nothing… from here on I can do whatever i want, progammer button is disabled (the upload just does not happen)… I re-connect everything, restart IDE, nothing happens. BUT, when I reboot my computer and try it, the first time it works, then from the second try to upload,… nothing … oO

what am I doing wrong?

Could you try to enable verbose mode for building in Teeensyduino (Settings)? Then, open PlatformIO IDE Terminal and run

pio run -t clean
pio run

Do you see significant difference in build flags?