I am trying to run two cmd files from the post-build event of a Delphi 2007 project.
The build events are configured like this:
..\..\buildtools\postbuild.cmd $(OUTPUTDIR)$(OUTPUTNAME)
..\copydlls.cmd $(OUTPUTDIR)
The first one works fine, the second one seems to never get called at all.
If I change the order like this:
..\copydlls.cmd $(OUTPUTDIR)
..\..\buildtools\postbuild.cmd $(OUTPUTDIR)$(OUTPUTNAME)
Again, only the first one is executed.
Is this a known limitation / bug of Delphi 2007 or am I doing something wrong here? (I could have sworn that this used to work in the past.)
EDIT: I found a workaround:
%comspec% /c ..\..\buildtools\postbuild.cmd $(OUTPUTDIR)$(OUTPUTNAME)
%comspec% /c ..\copydlls.cmd $(OUTPUTDIR)
This works as expected. Still odd.
EDIT2: There is another option, I found in this answer on StackOverflow:
call ..\..\buildtools\postbuild.cmd $(OUTPUTDIR)$(OUTPUTNAME)
call ..\copydlls.cmd $(OUTPUTDIR)
I guess (without having tried it), that is is a problem only if the build event is a cmd file and the past experience I cited above did not call cmd files but executables.
I guess the workaround I added in EDIT2 is the one that should be used, so I am adding this as an answer myself:
When calling cmd files (probably also bat files) a "call" must be added in front of it: