Unable to execute a .bat file in post build event command line

7.7k views Asked by At

My post build command is

call "$(ProjectDir)MyFile.bat"

And getting build error:

Error 1 The command "call C:\MyProject\MyFile.bat" exited with code 1. C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets 4548 5

What am I missing here? Working on TFS source code, is that the reason getting this error?

For testing in MyFile.bat the only code is mkdir MYTestFolder, but then I am also getting the same error.

2

There are 2 answers

5
miltonb On BEST ANSWER

It seems like the syntax of the call is correct. Therefore I believe it's failing inside the batch file. I suggest putting the first few lines of the batch to write the time into a log file, so you can confirm it's being called. Do this before any of the actual work, so it can be sure that the batch is being executed.

call "$(ProjectDir)MyFile.bat"

MyFile.bat

@echo off
echo time /t > MyTempFolderPath\logfile.txt
3
Ed Elliott On

It is the code inside the batch file that is failing - what is it doing?

You have a few options:

a - I would use process monitor and watch process exits and see the status codes of whatever the batch file launches.

b - You could also try running the batch file from the same folder as msbuild and see if you get any errors

Ed