Automate Advanced Installer with Ant

Originally published January 28, 2009.
Information provided in this post may be out of date.

Note: this post was updated in light of discussion on the Advanced Installer forum.

At work, we use Advanced Installer to create easy-to-use Windows installers for internal and external customers. I wrote a short Ant script for building the installer to save time and minimize mistakes.

If you use Advanced Installer with your Java projects, be sure to read my post on using the Advanced Installer licensing feature within a Java application.

Here is a partial Ant script for executing Advanced Installer builds. It’s not fancy, but it gets the job done. Notice the script has two parts – one for setting the version number of the product and another for doing the actual build.

<property name="installer.command" location="C:/Caphyon/Advanced Installer/AdvancedInstaller.com"/>
<property name="filename" location="C:/build/product.aip"/>

<exec executable="${installer.command}" failonerror="yes">
    <arg value="/edit"/>
    <arg value="${filename}"/>
    <arg value="/SetVersion"/>
    <arg value="${installerVersion}"/>
</exec>

<exec executable="${installer.command}" failonerror="yes">
    <arg value="/build"/>
    <arg value="${filename}"/>
</exec>

In the next snippet, which should be executed first, I’ve made the version number dynamic based on the current time, day, and month (but not year)! (The pattern may seem a little odd; it conforms to what Windows Installer expects.) Of course, this is completely optional and can be overridden using Ant command-line properties.

<tstamp>
    <format property="installerVersion" pattern="MM.dd.HHmm"/>
</tstamp>

When this script is combined with continuous integration, we have a repeatable, consistent, fully automated build of our software and its installer. And that rocks.