Visual Studio: Unable to upload firmware (unable to start platformio.exe error message)

After an installation from scratch (this is my first experience with this setup) , I have created a new VS project with

$ platformio project init --ide visualstudio --board esp-wrover-kit --project-option "framework=espidf"

The project compiles and builds

but does not upload the firmware when clicking image button. Instead, I get the error message:


There is something wrong in my installation but I don’t know what. Note that Python folders D:\DevTools\Python38\Scripts\;D:\DevTools\Python38\; are in my PATH. VS has not problem finding platformio when building but not when running.

I have made addtional checks. The board is visible

and I verified that I can establish serial connection with putty. I have specified COM4 in platformio.ini:

platform = espressif32
board = esp-wrover-kit
framework = espidf

and reinitialized the project with pio init -ide=visualstudio. I succeeded uploading manually with pio run -t upload -v. Thus, the problem is VS configuration. Debug:

and Release:

I did not change anything from default.