DOCUMENT:Q150287 14-MAR-2002 [visualc] TITLE :FIX: Custom Build Commands Fail When Built from Command Line PRODUCT :Microsoft C Compiler PROD/VER::4.0,4.1,4.2 OPER/SYS: KEYWORDS:kbusage kbide kbVC kbVC500fix kbGrpDSTools ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual C++, versions 4.0, 4.1 - Microsoft Visual C++, 32-bit Enterprise Edition, version 4.2 - Microsoft Visual C++, 32-bit Professional Edition, version 4.2 ------------------------------------------------------------------------------- SYMPTOMS ======== When you build a Microsoft Visual C++ project from the command line with Nmake.exe, the custom build commands you specify in the build settings fail, and cause the build to fail. However, when you build the project within Developer Studio, the commands work correctly. This behavior occurs when you specify multiple build commands for a file or group of files, and specify more than one output file that is created by the build commands. CAUSE ===== The problem is caused by a backslash (\) character added to the end of each build command in the .mak file. RESOLUTION ========== There are two possible workarounds: - Modify the .mak file, changing the \ at the end of each build command to an asterisk (*) character. Note that the IDE overwrites the .mak file whenever you change any project settings, and the \ is put back. -or- - Instead of specifying the multiple commands in the build settings, specify a single command that is a batch (.bat) file to invoke the commands. You need to pass parameters to the batch file in order to specify the input and output file names for the custom build commands. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 5.0. MORE INFORMATION ================ This behavior occurs because Developer Studio writes the makefile so the multiple commands are invoked on one command line. This causes the command interpreter (Cmd.exe on Windows NT, and Command.com on Windows 95) to report an error, because the result is not a valid command line. The commands need to be passed on separate command lines, or separated by a command line separator, such as the ampersand (&). Also, because there are multiple output files, the same commands are invoked repeatedly for each output file. Additional query words: kbVC400bug ====================================================================== Keywords : kbusage kbide kbVC kbVC500fix kbGrpDSTools Technology : kbVCsearch kbVC400 kbAudDeveloper kbVC410 kbVC420 kbVC32bitSearch Version : :4.0,4.1,4.2 Issue type : kbbug Solution Type : kbfix ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2002.