Why are my Custom Build steps not running in Visual Studio?
Asked Answered
C

2

16

I have a Visual Studio project with several Custom Build steps in it, but some of them are simply failing to run. There are no errors and no warnings, and according to the build logs they are running, but they're definitely not.

(It was all working in versions of Visual Studio prior to 2010, but it goes wrong in Visual Studio 2010 and later.)

Clear answered 10/9, 2010 at 17:33 Comment(0)
C
27

The reason it's failing is that there's another custom build step in the same project that's calling a batch file, like this:

Command Line: buildsomething.bat something.h
Description: Building something
Outputs: something.h

As of Visual Studio 2010, all the custom build commands are concatenated into a single batch file, which is then executed. When a batch file runs another batch file, Windows doesn't return control to the first batch file. It's like a goto, not a function call. So to fix the problem, you need to use call like this:

Command Line: call buildsomething.bat something.h

call makes the flow of control return to Visual Studio's batch file, and hence lets your other Custom Build steps run.

(I'm answering my own question so that future searchers can find the answer.)

Clear answered 10/9, 2010 at 17:34 Comment(2)
still true for MSVC 2017Totten
@YePhIcK: Thanks - I've updated the question and answer to reflect that.Clear
S
-1

Ensure that below two files are in good shape. Better compare these files against a working VS setup.

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets
Stephie answered 21/12, 2017 at 13:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.