Make sure you start from a x86 (or x64) Native Tools Command Prompt for VS 2022 (or 2019)
, depending which version of Visual Studio you have (VS 2022 or VS 2019) and which version of ROOT you installed (32 or 64 bit). And BTW, VS Code is not a platform and MinGW is irrelevant here (not supported by ROOT)