Build Script Question

I have a Web app that I deploy two different ways. There are a few changes in the compile so I created this build script and attached it to the Windows Build. I got some of the values for these properties in other forum posts.

Dim Targ as integer = 1

if Targ = 1 then
  Print "Building Version ONE - Close to continue"
  PropertyValue("App.WindowsAppName") = "Version1.exe"
  PropertyValue("App.Application Identifier") = "com.simplybasicsoftware.version1"
  BuildWebPort = 83
elseif Targ = 2 then
  Print "Building Version TWO - Close to continue"
  PropertyValue("App.WindowsAppName") = "Version2.exe"
  PropertyValue("App.Application Identifier") = "com.simplybasicsoftware.version2"
  BuildWebPort = 93
end if

I have the Behavior on the script (right side inspector) set to Release.

The PRINT statement actually creates a message box and tells me which selection that matches the current value of Targ.

This sort of works. BUT … When I set Targ=2 sometimes I get the correct message box corresponding to the Targ variable value but the build is for Version One.

It appears that the compiler gets the EXE file name BEFORE the script runs. I have not determined the values of the other properties are set correctly when the EXE name is wrong. I do know that when the EXE matches the selection in Targ the other properties are correct.

If I simply build a second time without changing anything and everything is correct based on the value of Targ.

I debug and build on a MacBook. The only output target for a build is Windows. I have tried to comment out the Print statement thinking that since it stops the compile until you close it somehow the compiler is confused but it makes no difference.

Any insight on running scripts at build time would be appreciated.

Thanks, Mark

and this is a a script that executes BEFORE the build step ?
as once the build step has executed running this script will affect the next build - not the one just done

I assume the order listed in the window on the left is the order of the build steps.

It is (top to bottom) in the build settings:

Copy Files

thats the right order then
just checking this is set up for the Windows target ?

the upside to this being basically an IDE script is that you can use File > IDE Scripts > New Ide Script and simply cut & paste and test your script there

I cant find any reason this shouldn’t be doing what you expect

Yes … The Windows target is the only one where I have any scripts. I only build for debug on my MacBook or Windows for production.

I do see the Xojo compile dialog (sheet) slide down FIRST with the wrong EXE file name when I click build then the message box that comes from my Print statement in the script has the correct EXE name.

Just for fun added a script in front of the current one with just a print statement and they happen in order but AFTER the Xojo compile dialog described above.

QUESTION - When does a script created with File > IDE Scripts execute?

when you RUN it
NEVER automatically
I tend to use it for testing things

Ahhhh …

That probably makes more sense anyway rather than editing a script before the build. I can create two scripts. One for each version and just run it before the build.

If I change the various properties in a script will they save the changed values if I save the project?

Can I do a SAVE and BUILD at the end of the script? What is the syntax? Finding stuff about scripting is not easy … unless you have some new help somewhere.


and if you use File > IDE Script > New IDE Script and press record and then do the things you want you should see it record the actions and you can copy paste etc from that

well this depends on if its an “internal” script (ie/ a build step script that is a “script”) or an external one
The external one would be saved as a separate file with a xojo_script extension and possibly created using File > IDE Scripts > New IDE script - or written using vi/emacs/pico or BBEdit. Notepad++ or any other text editor

And you’ll note that there are two “script” type steps for build scripts
One is an internal script and saved IN the project as part of the project
The other is expected to come from “outside” and the only thing that is saved as part of the project is the location of that script