Exception: Failed to locate env variables VS140COMNTOOLS or VS120COMNTOOLS
找到批处理vcvars.bat文件后运行,即可解决。vcvars.bat文件位置:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\vsdevcmd\ext
(根据安装路径不同而略有不同)
错误原因:
VS2017 has reworked its directory structure and filenames. The file is no longer titled "VsVars32.bat", you should look for the file 'vcvars.bat', which can be located in ..\Program Files (x86)\Microsoft Visual Studio\2017\EDITION\Common7\Tools\vsdevcmd\ext\vcvars.bat (using Adam's syntax, replace EDITION with the version of Visual Studio you use).
For simplicity, you can use %VSAPPIDDIR% in your call to point to the IDE folder where devenv.exe is located, and go back one folder to define your path to the batch file. For example:
call "%VSAPPIDDIR%..\Tools\vsdevcmd\ext\vcvars.bat"