I was setting up Automate Build for my VFP project. I get a copy of FinalBuilder and use it as my starting point for Daily Build and Continuous Integration. I choose FinalBuilder is because it is easy use, good support and easy installation. FYI, FinalBuilder is an automated build and release management solution (ABRM) for Windows software developers and SCM professionals. It is just one of the automate build tools in market. Other product like MS Build, NAnt, VSTS Team System and many more.

Automate Build

By using automate build tool, we could define, debug, maintain, run and schedule reliable and repeatable build processes with minimal coding required. Build process doesn't meant only compile project, it also include activities like Get Latest Source File, run database script, copy files to deployment server, package deployment files, run automated testing and etc Once build process is automated, we only need to have single mouse click to establish build process. After this implementation, I have shorten time spent to deploy new version of application from two hours to ten minutes.

Before we start to automate our build process, it is recommended to sit down, take some papers to draft out current manual build process, just like writing program. The draft could be in pseudo code, flow chart, point form or whatever format. It would definitely help and save our time without keep revising the automated build process during implementation. I wasted a lot of time to revise my Build Process.

Automated Build Management Solution - FinalBuilder

FinalBuilder, as other ABRM tool, provides a lot of predefined common actions to perform varies tasks such as get latest source files, compile projects, execute setup scripts, copy files, FTP and etc. We could use each of action by simple configuration. Below is the IDE screenshot of FinalBuilder and overview of my automate build process.

Figure 1 Screenshot of Build Process defined in FinalBuilder

Automate Build for VFP Project

During this implementation, I was facing some issues. The main issue is, FinalBuilder doesn't natively support VFP (as most vendors). That is no VFP compiler available. No VFP Compiler, are you kididng? This is the main tasks for automate build! Yes, you didn't hear wrongly.

Fortunately , FinalBuilder come with Action Studio, allow us to create custom actions for any specific usage via ActiveX Script (VB Script/JScript), .NET interop and COM.

VFP Compiler Custom Action

To write custom action, I did some researches and found article posted in CODE magazine titled Integrating VFP into VSTS Team Projects by John Miller.  John shared his code to rebuild VFP project file (PJX) from PJM file and BUILD EXE from project. I copied, customized posted code to create my "VFP Compiler" action, called from FinalBuilder. I added feature to explicitly compile all .prg files excluded from project, since I found that don't know why excluded .prg files are not compiled using BUILD EXE command.

At the beginning, I tried to use COM to wrapper my build project code, however, as you might already known BUILD command is not supported during run-time. VFP doesn't complain for this exception either. I spent a lot of time to troubleshoot this, as it is not documented in Help file (as least I couldn't find it :'(). The workaround is either call VFP via command line or OLE Automation. I choose the 2nd way, automate VFP IDE using VB Script.

Set oFox = CreateObject("VisualFoxPro.Application")
oFox.DoCmd("*** BUILD EXE")

'Do some other things

oFox.Quit

The "VFP Compiler" Custom Action created and allowed us to do configuration, and currently it only accept settings such as project to be built, output destination, runtime version, SET PATH list and strict date level.

Steps to setup

  1. Download the custom action here.
  2. Extract it, and copy FoxProFBCustomActions.fbp5 to "<Final Builder Path>\ActionDefs" folder. Copy ProjectBuilder.prg to any folder.
  3. Launch Final Builder IDE.  Action "Build Project and EXE" would be shown in Action Types List under category Visual FoxPro (Figure 2).
  4. Drag and drop action from action types list to action list (Figure 3).
  5. Action property page is shown.
  6. Specify any name as Build Name.
  7. Specify Project Name (PJM), with path. PJM extension could be omitted.
  8. Specify output destination and file name of project executable file. EXE extension could be omitted. If this field left blank, EXE would be built and store at same location and name of project file (PJM), with EXE extension
  9. Select runtime version to build the EXE and project (Figure 4).
  10. Specify search path list. Remember to include location that stored the ProjectBuilder.prg (Figure 5).
  11. Specify environment settings. Currently only support Strict Date Level (Figure 6).
  12. Click OK to confirm.
  13. New action would be added to action list (Figure 7).

Possible Enhancements

Some future enhancements I can think of :

  1. Ability to type VFP code in action property page, and run it at Before/After Compile event; either full VFP code or just a function call.
  2. Full set of environment settings available in VFP option dialog.
  3. Ability to VFP related actions global settings such as common library path list in FinalBuilder options page.

Figure 2 Some VFP Custom Actions



Figure 3  Drag action to action list

Figure 4 Build Project Settings

Figure 5 Set Path Settings

Figure 6 Environment Settings

Figure 7 Action to Compile Projects