XojoScript Keep Previous Builds

I use a XojoScript to build two Windows versions of the one Desktop app with slightly changed Constants. My problem is that when the second one goes to Build, it deletes everything in the Build folder (ie the first built application)!

Is there any way to ask Xojo in XojoScript to leave existing folders alone, or change the destination Build folder on the fly to a different folder?

On macOS I’d simply move the files away with an AppleScript or a shell script. What is the equivalent on Windows?

Edit: not sure why exactly you want to keep the files after building. Please explain with more detail.

1 Like

As I’m understanding David, the builds are slightly different based on the constants. I do the same for a client who prefers separate executables for their Pro and Standard versions of a program.

My build script equates to roughly

  1. App.kPro = True
  2. Build
  3. Rename Pro build
  4. App.kPro = False
  5. Build

The end result is that both versions are there. David, you should try something like step 3 where you either rename or move the first build.

2 Likes

Here is my XojoScript where it runs two Builds for the one application by changing the App.WindowsAppName constant. It builds the BlackDogCRM exe in the Windows>BlackDogCRM folder, but when it runs again to build the BlackDogSRM exe, it removes the Windows>BlackDogCRM folder!

I am running on the latest macOS with the latest Xojo, but building for Windows. I tried previously to run a Shell command to move the first Build folder, but it returned with a permissions error. I haven’t tried an AppleScript.

How can I ‘rename or move the first build’ in XojoScript?

Dim appNames() As String = Array ("BlackDogCRM", "BlackDogSRM")
Dim BaseName As String

For tempInt As Integer = 0 To appNames.ubound
  BaseName = left(appNames(tempInt), 8)
  SelectWindow BaseName
  PropertyValue("App.OptimizationLevel") = "4" 'Default = 0, Aggressive = 4, Moderate = 6
  PropertyValue("App.Application Identifier") = "com.holymackerelsoftware." + appNames(tempInt)
  PropertyValue("App.MacOSXAppName") = appNames(tempInt)
  PropertyValue("App.Description") = appNames(tempInt)
  PropertyValue("App.WindowsAppName") = appNames(tempInt)
  PropertyValue("App.ProductName") = appNames(tempInt)
  PropertyValue("App.InternalName") = appNames(tempInt)
  PropertyValue("App.FileDescription") = appNames(tempInt) + " by HMS"
  path = BuildApp(kWin32, True)
Next
'reset the values
PropertyValue("App.OptimizationLevel") = "0"
PropertyValue("App.Application Identifier") = "com.holymackerelsoftware." + BaseName + "CRM"
PropertyValue("App.MacOSXAppName") = BaseName + "CRM"
PropertyValue("App.Description") = BaseName + "CRM"
PropertyValue("App.WindowsAppName") = BaseName + "CRM"
PropertyValue("App.ProductName") = BaseName + "CRM"
PropertyValue("App.InternalName") = BaseName + "CRM"
PropertyValue("App.FileDescription") = BaseName + "CRM" + " by HMS"
PropertyValue("App.LinuxAppName") = BaseName + "CRM"

Speak("Finished Building " + BaseName)

Since you are building on macOS, I suggest using ditto instead of cp. It should be executed right after you do the build.

If you’re running into a permissions error, I’d say it’s probably iCloud syncing getting in your way. I can think of two ways to handle that:

  1. Rename your working directory (even temporarily) to have a suffix of .nosync so iCloud won’t try to sync.
  2. Add a shell call to sleep to wait a few seconds for everything to settle down.

Thank you @Greg_O, ditto works where mv fails on macOS.

1 Like