Using compiler variables to customize setup at build time

Hello everyone, I hope you’ve all been well!

This post’s topic: How to customize your setup at build time. This could be used for different products, when only very few things change between them, and having a unique setup project for each one turns into a major copy and clone nightmare. It’s really a quite common scenario to have similar products using similar setup routines. At InstallAware, we actually ship a single installer that contains all four of our product editions – allowing users to choose at runtime which version they want to install. We might cover that in a later post; for now we’ll look at how to customize your installations at build time – emitting multiple “flavors” of a setup, if you will. This is where Compiler Variables come into play.

Compiler Variables are defined inside the Project Options window. To bring up this window, click the Project Settings button, found inside the Manage group of the Design tab.

Choose the Compiler Variables section and you’ll see three buttons, Add, Edit and Delete. This is where you define and set the initial values of your Compiler Variables. These variables are accessed using the #COMPILER_VARIABLE_NAME# format inside your MSIcode script. You may use these variables anywhere inside your script. Even MSIcode command fields which do not ordinarily accept variables will take compiler variables, since compiler variable values are “burnt-in” at build-time, and do not change at runtime.

In addition to replacing literals with values injected at build time, another use of compiler variables is to conditionally include/exclude parts of your MSIcode script. Use the Compiler Variable If, Compiler Variable Else and Compiler Variable End MSIcode commands to include/exclude parts of your setup project at build time. This adds a lot of flexibility to how you can build setups at runtime – you can take out whole blocks of MSIcode script, completely changing your setup logic and files – all at build time, and without needing to use complex automation.

Here’s a short list of what you can customize with compiler variables, among other things:

  1. Product name
  2. Product version
  3. Product code
  4. Files being installed
  5. Features being built

Take look at the code below to see what I mean:

As you can see, one of my compiler variables is “MYPRODUCT” and its defined/initialized on the Compiler Variables section of the Project Options window. The above code builds some files and features if the compiler variable “PRODVERSION” is equal to “Enterprise” but excludes one file if the compiler variable “SUBVERSION” is not equal to “Full”.

You might also want to take a look at the pre-defined compiler variables that already exist in InstallAware. There are two kinds of pre-defined variables – pre-defined compiler variables and pre-defined script/runtime variables – so don’t get confused between the two. Both of these pre-defined variable kinds come in real handy for lots of things, like figuring out the execution path of your setup. I’d definitely encourage you to take a look at them. Just search for pre-defined variables and pre-defined compiler variables in the help index.

My favorite compiler variables are the following:

  1. LOADOLDDATA: Instructs the setup engine to migrate feature selections from older versions.
  2. PROJDIR: Resolves to the project directory on your system.
  3. LOADOLDDATA: Instructs setup to change the way in which localizations are applied at runtime (see the help file for details).
  4. BUILDMODE: Resolves to CD, SFX, WEB, or PATCH based on your setup build mode.
  5. TITLE: Resolves to the name of the setup project.

Thank you,

Panagiotis Kefalidis
Software Design Team Lead
InstallAware Software Corporation

9 Replies to “Using compiler variables to customize setup at build time”

  1. Hello,

    Very nice post, that what I was looking for.

    However, I need your help for the following:

    Assuming that I have changed the script accordingly so that it takes care of the various values of the Compiler Variables.
    Now, If I save the project with different names that each one has the “correct” Compiler Variable values and different Build-Output-Custom Folders specific for each project, will this be OK to have the different setups?

    TIA,
    Emmanouel

  2. or look to your packgae name. It may be that your packgae name conflicts with some other packgae that’s either a built-in or otherwise. In my case I had a packgae actor . A class inside that packgae defined a public function, but I kept getting this error. Changing the packgae name arbitrarily (eg: actorx ) suddenly made the problem disappear.

  3. I have really learned new things by means of your blog site. One other thing I’d like to say is the fact that newer laptop os’s are inclined to allow far more memory to be used, but they likewise demand more memory simply to work. If one’s computer is unable to handle extra memory along with the newest computer software requires that storage increase, it can be the time to shop for a new Computer system. Thanks

  4. A number of us learn all pertaining to the engaging choice anyone present strong steps within this website and for that reason powerfully inspire factor through some other versions for this topic although our very own kid is really discovering lots. Like the residual portion of the year.

  5. I do not know whether it’s just me or if everybody else experiencing problems with your blog. It looks like some of the written text on your content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them too? This could be a issue with my browser because I’ve had this happen previously. Cheers|

  6. Simply wish to say your article is as astonishing. The clearness in your post is simply nice and i can assume you are an expert on this subject. Well with your permission allow me to grab your feed to keep updated with forthcoming post. Thanks a million and please carry on the enjoyable work.|

  7. I think that is among the such a lot vital information for me. And i am glad reading your article. However wanna remark on few normal issues, The website taste is wonderful, the articles is really excellent : D. Good process, cheers|

Leave a Reply to Peggy Aldana Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.