views:

2813

answers:

5

Basically what I need is an automated way to update the product version number in WiX (3.0 with Votive etc), and then get that version number into an Inno Setup "bootstrapper"

I pretty much have the process mostly automated, however version numbers still need to be updated manually which obviously isn't ideal, but I couldn't find how to pass in values to Inno Setup at compile time (and how to reference them), and in the WiX project I need to know how to reference the version number of a different project in the same solution in Visual Studio 2008

+1  A: 

The way I do it is with a WSF script (I use JavaScript but you could use VBScript or even an SH script using Cygwin) that creates a header file containing definitions for the version numbers. You can use the Wix <include> statement to drag the version number in.

For Inno Setup I create a .iss file that contains the version number, which is #included into the main iss script.

I am at home but can post some sample code tomorrow if you like.

EDIT: I forgot to mention that I run the script that generates the files containing the build number during the pre-build stage of my various VS projects.

Rob
I'd appreciate sample code if you don't mind :) Thanks
Davy8
A: 

I found this for the inno setup section which looks like it would work:

http://agiletracksoftware.com/blog.html?id=4

Davy8
Yeah, but why go through all that trouble when you can simply have the Inno compiler get the numbers from the source binary's version info resource (see my answer)? Avoid double-housekeeping (such as manually putting the version both into the resource and some text file) wherever possible.
Oliver Giesen
+1  A: 

Some sample code as promised. This should be enough to get you started.

The following JavaScript can be used to create an InnoSetup iss file containing the version number. The actual file will look like this:

VersionInfoVersion=1.2.3.12345
AppVerName=My App v1.2.3.12345

The main Inno Setup script will include this file by adding the following to the end of the [Setup] section:

[Setup]
AppId={{...}}
...

#include "version.iss"

Here is the JavaScript (this would be saved as a separate file - version.js for example):

createInnoSetupIncludeFile("My App", 1, 2, 3, 12345, "version.iss");

function createInnoSetupIncludeFile(appName, verMajor, verMinor, verSubMinor, buildNumber, headerFileName)
{
    var versionString = verMajor + "." + verMinor + "." + verSubMinor + "." + buildNumber;
    var fileSystemObject = WScript.CreateObject("Scripting.FileSystemObject");
    var fileObject = fileSystemObject.CreateTextFile(headerFileName, true);
    fileObject.WriteLine("VersionInfoVersion=" + versionString);
    fileObject.WriteLine("AppVerName=" + appName + " v" + versionString);
    fileObject.Close();
    fileObject = null;
    fileSystemObject = null;
}

You could tweak this script to create the version.iss file in a different folder.

Finally you need to execute the JavaScript - the best place would be in the Pre-Build Event of your Visual Studio project. Add the following:

cscript version.js //NoLogo

You would need to change this to also build a Wix compatible include file. I used to do this, but dumped Wix in favour of Inno Setup, so I don't have this code to hand. There is a mechamism for a Wix script though, so that should point you in the right direction - the concept is the same - generate a text file that defines the version number and then include it.

Hope this helps.

Rob
Thanks, not sure whether I'll go with yours or Oliver's yet but +1 to both of you :)
Davy8
+13  A: 

No need to pass anything! You can simply let the InnoSetup Preprocessor read the version info straight from the binary's version resource, e.g.:

#define AppName "My App"
#define SrcApp "MyApp.exe"
#define FileVerStr GetFileVersion(SrcApp)
#define StripBuild(str VerStr) Copy(VerStr, 1, RPos(".", VerStr)-1)
#define AppVerStr StripBuild(FileVerStr)

[Setup]
AppName={#AppName}
AppVersion={#AppVerStr}
AppVerName={#AppName} {#AppVerStr}
UninstallDisplayName={#AppName} {#AppVerStr}
VersionInfoVersion={#FileVerStr}
VersionInfoTextVersion={#AppVerStr}
OutputBaseFilename=MyApp-{#FileVerStr}-setup

For some inexplicable reason ISPP is not included in the default InnoSetup package. The easiest way to get it is to download the InnoSetup Quick Start Pack: http://www.jrsoftware.org/isdl.php#qsp

Oliver Giesen
Wow! That's brilliant! +1.Annoyed that ISPP isn't part of the default package.
Rob
+1 You can pull all the versioninfo values from your exe. I've used Inno (and ISTool) for several years now for all my products, and I think it's rather... beautiful.
Spike0xff
+4  A: 

You can get the ProductVersion for WiX from a file version in your package. Syntax is something like:

<Product Version="$(var.FileVersion.FileId)">

Or you can provide it on the command line to candle using the "-dVersionFromCommandLine=1.0.0.0" switch with syntax like:

<Product Version="$(var.VersionFromCommandLine)">

Either works in latest builds of WiX v3. Only the latter works on WiX v2.

Rob Mensching