cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
leontiev
Level 3

How to set component version at build time?

Hi

I looking for a way to send component version at build time. The only thing that i found is setting the product version, either by defining it directly in the command line with "build.exe MyProduct.iap_xml productVersion=2.1.3.24" or using buildproperties file with following structure:



ProjectVersionMajor="2"

ProjectVersionMinor="3"

ProjectVersionRevision="1"

ProjectVersionSubrevision="24">








But i don't see a way to change component version. Is it possible without opening InstallAnywhere UI?

Thanks
Labels (1)
0 Kudos
4 Replies
greenaj
Level 3

I don't think you can. I posted about this in http://community.flexerasoftware.com/forumdisplay.php?288-InstallAnywhere-2012.

No one has answered me yet, I would like to find a Flexera approved method of supporting this. I resorted to modifying the component version contents using Python scripting with some XPath navigation and XML document manipulation libraries (lxml etree). For such, PowerShell, VBScript + MSXML, Ruby, etc. should work just fine. Just be sure that the XML declaration of the modified project that you save is NOT or you will get some freakish error messages echoed to STDOUT about the xml attributes being invalid when doing a command line build. The package will still build, and the single quotes are standard and should work, but InstallAnywhere's build give you some spooky messages.

The best way to find the component you are interested in is using the following XPath expression: (NOTE: This is Python 3)

r = root.xpath('/InstallAnywhere_Deployment_Project/installationObjects//object[@class="com.zerog.ia.installer.InstallComponent" and ./property[@name="componentName"]/string[.="YOUR_COMPONENT_NAME_HERE"] ]')
if len(r):
prjFileIsModified = True
r[0].find("property[@name='versionMajor']/int").text = vers[0]
r[0].find("property[@name='versionMinor']/int").text = vers[1]
r[0].find("property[@name='versionRevision']/int").text = vers[2]
r[0].find("property[@name='versionSubRevision']/int").text = vers[3]

Where "YOUR_COMPONENT_NAME_HERE" is the name of your component. That frees you from having to use the objectID attribute or the component guid. You see, I think that the ... in the XML forces you to use and integer as opposed to a build variable. Advanced designer won't even let you enter a variable for any of the 4 version values (Major, Minor, etc.).

Good luck. This should be more easily addressed for automated builds.

I tried to use the InstallAnywhere automation API, but I can't get it to work reliably. If you open up a project in Java and simply save it someplace else, I have been getting a lot of information stripped out. If you managed to get that to work, I would love some advice.
0 Kudos
nosrednayduj
Level 7

I also resorted to modifying the .iap_xml file. I did it with a java program, and I was unable to use the regular java DOM API because when it wrote out the resulting file, it wrote out as , which should be equivalent, but IA treats it differently and I got some strange errors about "null" when it should have given me an empty string. So I had to use textual manipulation, which fails when IA changes something just a little bit.
0 Kudos
Jeff_Morse
Level 6

Maybe you have already figured this out but I'll post anyway how we handle it and maybe help others. We use a template.iap_xml project file checked into source code that has @VERSION_MAJOR@, @VERSION_MINOR@, @VERSION_REV@, and @VERSION_SUBREV@ tokens in place for the product's and components' versions. We use ant to build our installers. Ant loads a properties file containing the version (and other) properties. Ant first creates a modified.iap_xml that has the correct version numbers, then builds installer(s) from that. One caveat to this process is you cannot load template.iap_xml in the Advanced Designer because it doesn't like @VERSION_MAJOR@. You must work in the modified project file and merge your changes back to the template before check-ins. Another option could be to use XSLT.

-Jeff
0 Kudos