What errors are you getting? I guess it is a failure like this:
xtensa-esp-elf-g++.exe*: fatal error: cannot specify -o with -c, -S or -E with multiple files
An error was encountered during the 'Deep Search' library discovery process.
I have problems with versions newer than 3.1.0 that are being investigated.
I found that if you try a version newer than 3.1.0 that fails then go back to 3.1.0 it also fails.
Going back to 3.0.7 works but to move to a newer version you need to manually delete the folders that are in in the c:\Users\<Your User>\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs
There will probably be several if you have tried installing different versions - there should only be 1 there. You can check the bad ones as the sub folders (i.e. esp32) will only have the include folder and nothing else, there should be several folders and 3 files.
If you then install V3.1.0 using the board manager you should get a single folder idf-release_v5.3-083aad99-v2 and you can build with 3.1.0
If you try to install any newer versions you will have the same problem and the build will fail. Then you will need to delete the folders again as above.
This was my experience and how I fixed it.
The VM team are investigating and I am sure will fix it soon but for now the highest version I have been able to install has been V3.1.0