11

I'm interested in figuring out how to automate a build from Visual FoxPro similar to how we can build .NET projects from the command line using MSBuild.

It seems that it is possible to pass command line arguments to VFP.exe which may include the ability to specify some initial startup prg that runs however it is unclear how well starting up the IDE will work from non-interactive accounts such as the Network Service on Windows which is likely where an automated build would run.

Has anybody attempt this before or read about anybody attempting to script a VFP build like this? I would be grateful for any pointers that may lead me to a solution.

jpierson
  • 13,736
  • 10
  • 94
  • 137

2 Answers2

20

A simple solution is to create a program file that builds the application, and call VFP to execute that program. You can also add any pre or post build commands to that program file.

Create a VFP configuration text file, called BUILD.FPW

SCREEN=OFF
COMMAND=DO C:\Project\BUILD.PRG

Then create C:\Project\BUILD.PRG

Modify Project C:\Project\MyProject Nowait
_vfp.Projects.Item(1).Build("C:\Project\myapp.exe", 3, .f., .f.)
If file("C:\Project\myapp.err")
    * Do something for build errors
Else
    * No errors
Endif
Quit

Finally, to build it

C:\Program Files\Microsoft Visual FoxPro 9\vfp9.exe -CBUILD.FPW

VFP will build it non-interactively. It will log build errors to myapp.err. If it builds successfully, no error file is created.

Chris Vesper
  • 636
  • 8
  • 18
  • I think this is the answer I need but FoxPro was soooo long ago for me. When I do exactly what you say above I get: 1689 Cannot build without a main program. What is C:\Project...Project root or where all my prg files live or...??? – GPGVM Dec 06 '19 at 16:33
  • @ GPGVM: the parameter for the `modify project` command is the full pathname of an existing project file, in this case `C:\Project\MyProject`; the extension '.pjx' is implied and may be omitted. If the path contains blanks then it must be enclosed in quote characters (e.g. `modify project 'c:/subdir/name containing blanks' nowait`). – DarthGizka Dec 09 '19 at 13:07
3
abmv
  • 6,716
  • 16
  • 59
  • 99