Does Microsoft Visual Studio 2010 not install build tools in PATH for a clean purpose?

I configured Microsoft Visual Studio to use the Makefile configuration type, and I wrote a makefile to create my project using Microsoft tools. In the NMake section of the project configuration, I installed the build build.bat assembly, which is a file that simply calls nmake with my make file as a command line argument, for example:

nmake /nologo /f makefile.x86.winnt.msvc2010 

This works great.

For cleaning, I wrote a target in my makefile, which removes all assembly artifacts. It looks like this:

 #... the rest of the makefile clean: @erase /f /q $(OBJS) $(OUT) $(MAPFILE) $(PDBFILE) @echo + clean 

Therefore, I set a clean command line as a call to nmake with a clean argument. Like this:

 nmake /nologo /f makefile.x86.winnt.msvc2010 clean 

I put this text in clean.bat and set it as "Clean command line", but it does not work because the calling shell cannot find nmake. I checked the path during a clean call, and MSVS does not include build tools in the path (including nmake) to clear. (Note that the above nmake command is executed from a shell that has nmake in PATH).

How can I get MSVS to enable build tools in PATH so that I can invoke nmake on a clean command line? Or is there a better solution?

+4
source share
3 answers

Quote from the Visual Studio Express Readme :

2. Known issues

2.4. Product issues

2.4.1. General questions (product)

2.4.1.14. Pure solution does not work for configuration type: Makefile (2010 RC)

Running a "clean solution" in a nmake solution reports the following error:

 1>------ Clean started: Project: makefiletest, Configuration: Debug Win32 ------ 1> 'nmake' is not recognized as an internal or external command, 1> operable program or batch file. 1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.MakeFile.Targets(33,5): error MSB3073: The command "nmake /?" exited with code 9009. ================= Clean: 0 succeeded, 1 failed, 0 skipped ========== 

To fix this problem:

  • Open a Visual Studio command prompt window.
  • Open Devenv by typing devenv /useenv .
  • Now the Clean Solution should work.

Or:

Pass the batch file to the clean command. In the batch file, configure PATH for the nmake tool as well as for another build environment.

+4
source

Of course you're right, MSVC never puts its build tools on the road! So, you have two options:

  • Run the batch file from the VisualStudio command prompt

  • Add %ProgramFiles%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat to run the batch file to add the necessary PATH path.

+3
source

I think the best solution is to add set PATH=$(VSInstallDir)\BC\bin;%PATH% to the top of your batch file.

This should guarantee future builds if you upgrade to VS2012 (or beyond) in the future.

0
source

Source: https://habr.com/ru/post/1441397/


All Articles