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
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
Before version 5.4.1 (2011-02-09) ISPP was not included in the default InnoSetup package. You had to download the InnoSetup Quick Start Pack: http://www.jrsoftware.org/isdl.php#qsp (thanks @Gwyn, for the update)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With