Location of nmake in VS2019 is not generic. Or am I missing something?

Viewed 1247

I am creating a generic script to deploy on the build server to build our project using VS 2019. The location of nmake in VS 2019 is at: C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133\bin. The inclusion of numbers like 14.29.30133 doesn't allow the script to be very generic. In the earlier generations of VS, nmake paths were like: C:\Program Files\Microsoft Visual Studio 10.0\Vc\bin or C:\Program Files (x86)\Microsoft Visual Studio 11.0\Vc\bin

Maybe I installed MSVC incorrectly? Any help is appreciated. TIA.

1 Answers

You installed MSVC correctly, and yes, this can cause some headaches, because the version number in the folder name changes with every new minor release of VS 2019.

To resolve this, use this command line snippet for getting the path to the latest installed nmake.exe into the variable %NMAKE%:

 set VSPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional
 for /f %%i in ('dir "%VSPATH%\VC\Tools\MSVC" /b') do set VCTOOLSVERSION=%%i
 set NMAKE="%VSPATH%\VC\Tools\MSVC\%VCTOOLSVERSION%\bin\HostX86\x86\nmake.exe"

This works for all intermediate versions of Visual Studio 2019 I tested it with.

Related