You can pass the version to the MSBuild script for your setup project the same as you can pass for application's build script.
For example, if your CI system defines variables AppVersion
and BuildNumber
, and passes them to your MSBuild scripts, your wixproj can create a corresponding Version
property which it forwards to Wix like this:
<PropertyGroup>
<Version Condition=" '$(BuildNumber)' == '' ">0.0.1</Version>
<Version Condition=" '$(BuildNumber)' != '' ">$(AppVersion).$(BuildNumber)</Version>
<DefineConstants>Version=$(Version)</DefineConstants>
</PropertyGroup>
The first definition of Version
provides a default for when you're building locally. Whatever it ends up with becomes a Version
variable in Wix. Use it in a wsx file like this:
<Product Version="$(var.Version)" ...>
<Package Description="$(var.ProductName) $(var.Version): $(var.ProductDescription)" ... />
I like to include the version in the description so that it's easy to look up from Window Explorer (as a column in Detail view or on the Properties page) independent of the file name.
Passing the version as a variable gives you more control than reading it from a file. When you read from a file, you get all 4 parts of the programmatic version. However, ProductVersion is only designed to use the first 3 parts.