Question

My target is to auto-name the output msi file with version number in WIX 3.6 project. I find this link: Automated installer version numbers for WiX, revisited but we have a slightly different scenario: we don't want to control our product version number by referencing to any assembly's version number. Instead, we just simply want to assign it in wix files. Specifically, I have a wxi file which defines a property like this:

<?define VersionNumber = "1.1.2000" ?>  

As a result, I can use this VersionNumber variable anywhere inside our Product.wxs file. But since the easiest way to rename the output msi file seems to be adding a postbuild task in MSBuild, I must pass this VersionNumber out to the MSBuild project file. This is what stops me.

I tried the other way around, i.e., to define the VersionNumber constant in the MSBuild and use it inside WIX. It works fine except I must keep this constant the same for different Build/Platform combinations. We are building our software in VS IDE which means if we modify the version number in IDE's window, it would only apply to the specific Build/Platform combination and the other combinations will remain unchanged(I know if I am building from command line I can simply pass a version number to overwrite the existing one). And that is what I don't want to see. I like the idea to only define the version number in one place to avoid any possible mistake.

Any help will be appreciated!

Was it helpful?

Solution

Define the preprocessor variable after choosing "All Configurations" and "All Platforms" in the Build tab of the setup project properties.

You can achieve this by adding an element in your .wixproj to a project where you just keep the version number. You'd modify the .wixproj, but only once. And you can probably add this properties file to the .wixproj itself with a reasonable action (None?) so you can modify it from within the IDE.

Something like:

Version.properties

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <WhateverTheVersionPropertyNameIs>x.x.x.x</WhateverTheVersionPropertyNameIs>
  </PropertyGroup>
</Project>

In your .wixproj file you'd add at the end

<Import Project="Version.properties"/>

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top