Wifi Password in build_flags

Hi,

I’ve setup a small test project utilizing wifi of my ESP32 (DoIt DevKit).

The password starts with a $ and this seems to cause trouble.
When hardcoding the password or defining a var like this, it is working:

const char *password = "$test&Password$";

// OR

#define WIFI_PW "$tes&tPassword$"

#pragma message "Wifi Value " WIFI_PW

When defining the password in the platformio.ini as build_flags it becomes weird.

build_flags = 
    '-D WIFI_SSID="ssid"'
    '-D WIFI_PW="$test&Password$"'

outputs note: #pragma message: Wifi Value


build_flags = 
    '-D WIFI_SSID="ssid"'
    '-D WIFI_PW="\$test&Password$"'

outputs

Generating LD script .pio/build/serial/memory.ld
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file

build_flags = 
    '-D WIFI_SSID="ssid"'
    '-D WIFI_PW="\\$test&Password$"'

outputs

<command-line>: warning: unknown escape sequence: '\&'
src/main.cpp:11:31: note: in expansion of macro 'WIFI_PW'
 #pragma message "Wifi Value " WIFI_PW
                               ^~~~~~~
<command-line>: note: #pragma message: Wifi Value &Password$
src/main.cpp:11:31: note: in expansion of macro 'WIFI_PW'
 #pragma message "Wifi Value " WIFI_PW
                               ^~~~~~~
<command-line>: warning: unknown escape sequence: '\&'
src/main.cpp:14:24: note: in expansion of macro 'WIFI_PW'
 const char *password = WIFI_PW;

Maybe this is the wrong approach of passing wifi credentials to my firmware.
How could I overcome this problem?