Friday, March 20, 2009

Post build scripts

With the changes in how Windows applications are built it can sometimes be hard to get your debug session set up the way you need.
There are a couple of choices:
  1. use run paused and manually COPY items from one location next to your debug application

  2. use a post build script so you can set it up once and then just hit run like always

PostBuild scripts run after the compiler has compiled your application but before the debugger has started your application.

The set up for a PostBuild script is fairly straight forward (I'll use our case as an example)
  1. next to your project file create a directory called "Scripts"

  2. create a new IDE Script, add the required code to do your copies and save it into this directory as "PostBuild.rbs"

Our script contains the following :

#if TargetWin32
dim s as string
s = DoShellCommand( "xcopy /E/C/Y %PROJECT_PATH%\Framework " + CurrentBuildLocation + "\Framework\", 99999)
s = DoShellCommand( "xcopy /E/C/Y %PROJECT_PATH%\Resources " + CurrentBuildLocation + "\Resources\", 99999)

These two commands copy the entire contents of the Frameworks and Resources directories from directories next to the project file into the newly build debug app.

You might want to put all your debug resources (pictures , dll's, etc) in a directory next to the project file and then just use xcopy to copy the contents of that into the directory where the debug app got built to.


Tim Hare said...

Will post-build scripts be Studio only now?

Norman said...

They are just IDE scripts with specific names the IDE looks for

Steve Garman said...

@Norman At the risk of appearing dim, is that a yes or a no?

Norman said...

yes since IDE scripting will only be in studio

PC said...

How would you do this on a Mac?

jimme said...

its really helpful information,
i am going to bookmark it for future

Geoff Perlman said...

I think by "Studio" you mean "Enterprise".