从命令提示符获取Windows nmake版本?

时间:2019-04-29 13:42:50

标签: windows command-prompt nmake

我不太了解nmake,但是在Windows 10下使用“ x64 Native Tools Command Prompt for VS 2017”中的nmake;我想从命令提示符处找到此工具的版本。

我发现了这个:

https://docs.microsoft.com/en-us/cpp/build/reference/batch-mode-rules?view=vs-2019

  

要检查NMAKE版本,请运行NMAKE 1.62或更高版本提供的_NMAKE_VER宏。此宏返回一个表示Visual C ++产品版本的字符串。

...但是我真的不知道如何“运行宏”-我尝试过:

C:\>nmake _NMAKE_VER

Microsoft (R) Program Maintenance Utility Version 14.16.27026.1
Copyright (C) Microsoft Corporation.  All rights reserved.

NMAKE : fatal error U1073: don't know how to make '_NMAKE_VER'
Stop.

因此,它删除了类似版本字符串的内容,但仍然存在错误。

因此,如何从命令行正确获取nmake版本?

1 个答案:

答案 0 :(得分:0)

正如Hans Passant所建议的那样,您可以考虑输入nmake/?;这将为您提供从问题中已经知道的信息,即14.16.27026.1

变量_NMAKE_VER的目的是允许您从Makefile中的内测试nmake版本或Visual Studio版本。例如,假设您的makefile是:

 # Check the first three characters of _NMAKE_VER to
 # obtain the Visual Studio version:
 !if [cmd /c if "%_NMAKE_VER:~0,3%"=="14." exit 1]
 !  message Using VS 2017, with NMAKE $(_NMAKE_VER)
 !elseif [cmd /c if "%_NMAKE_VER:~0,3%"=="12." exit 1]
 !  message Using VS 2013, with NMAKE $(_NMAKE_VER)
 !else
 !  message Unknown VS version, with NMAKE $(_NMAKE_VER)
 !endif

 # Just output _NMAKE_VER:
 all:
      @echo "Version             NMAKE" $(_NMAKE_VER)

然后从Visual Studio 2017开发人员命令提示符处发出以下命令:

 nmake /nologo

将提供(在我的计算机上):

 Using VS 2017, with NMAKE 14.10.25019.0
 Version             NMAKE 14.10.25019.0

或Visual Studio 2013:

 Using VS 2013, with NMAKE 12.00.21005.1
 Version             NMAKE 12.00.21005.1

我们需要使用DOS cmd来检查_NMAKE_VER,因为nmakegmake的字符串处理工具有限。

编辑:上述测试可能无法区分VS 15和VS 17,因为VS 17 nmake的版本号以14开头,而不是预期15