" Maybe something about the PATH breaks the MSBuild command line tools in Visual Studio 2017."
A while ago I had an issue with my builds caused by having a polluted path.
I had an exe called rc.exe in my path. However, it wasn’t Microsoft’s RC (Resource Compiler), it was just a executable named rc.exe and CMake tried to use it to compile a project. And it obviously failed since my rc.exe had nothing to do with C/C++ compilation. Once I removed the offending PATH from my system and rebooted everything worked fine.
Maybe it’s a similar thing?