Onega

a lot of VC++ posts, a few C# posts, and some miscellaneous stuff

Monday, June 05, 2006

run output file as a post build step

If you just put $(TargetPath) as command of post build event, the it does not work.
Here is a working solution.

Create a vbscript file under your project folder (post_build.vbs)

if WScript.Arguments.Count > 0 Then
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run WScript.Arguments.Item(0)
set WshShell = nothing
End if

Set the following command line in post build command:
cscript.exe $(ProjectDir)\post_build.vbs $(TargetPath)

You can also use script in pre-build event, the advantage is that a build
won't be stopped by error of pre-build event, such as failure to stop a
service when you are working on a service project.

Another sample is copying 3rd party files at post-build event:
if not exist $(TargetDir)TestRunnerd.dll copy \cppunit\lib\vc90\TestRunnerd.dll $(TargetDir)

0 Comments:

Post a Comment

<< Home