Post event build exit with code 1 error in Visual studio 2013

1k Views Asked by At

Here is the script:

copy /y "$(SolutionDir)Libs\Detect.dll" "$(SolutionDir)$(ConfigurationName)"
call editbin.exe /LARGEADDRESSAWARE SER.EXE > post.txt
call dumpbin.exe /HEADERS SER.EXE > post1.txt

The error is

Error 306 The command "copy /y "C:\dev\blah\Libs\Detect.dll" "C:\dev\blah\Debug" call editbin.exe /LARGEADDRESSAWARE SER.EXE > post.txt call dumpbin.exe /HEADERS SER.EXE > post1.txt" exited with code 1.

1

There are 1 best solutions below

0
On BEST ANSWER

Post event build exit with code 1 error in Visual studio 2013

Only one thing needs to be confirmed: Is this SER.EXEexecuted only in the release mode or just this SER.EXE is exist in the release folder and should be executed in the debug and release mode?

If this SER.EXEonly need to be executed in the release, Lex`s suggestion should to be considered. Pre- and Post-Build Events run as a batch script. You can do a conditional statement on $(ConfigurationName). For example:

copy /y "$(SolutionDir)Libs\Detect.dll" "$(SolutionDir)$(ConfigurationName)"
if $(ConfigurationName) == Release call editbin.exe /LARGEADDRESSAWARE "SER.EXE"> post.txt
if $(ConfigurationName) == Release call dumpbin.exe /HEADERS SER.EXE > post1.txt

If this SER.EXE is exist in the release folder and should be executed in the debug and release mode, you just need to specify the release folder in the command:

 call editbin.exe /LARGEADDRESSAWARE "Release\SER.EXE"> post.txt
 call dumpbin.exe /HEADERS "Release\SER.EXE"> post1.txt

Obviously, you also need make sure the SER.EXEcan be executed, you can use below command to test in the console application project:

call editbin.exe /LARGEADDRESSAWARE "$(TargetPath)"> post.txt

Note: When you want use this post-build event in both debug and release mode, you should add the command line for all configuration, Otherwise this command will only act on one mode (Just a reminder):

enter image description here

Hope this help.