wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
130 stars 24 forks source link

Add preprocessor variable with WiX version #4821

Open wixbot opened 9 years ago

wixbot commented 9 years ago

I have some WiX projects that I'd like to be able to use on multiple machines which each may have a different version of WiX 3.x installed.

It would be nice to be able to conditionally include/exclude code depending on which version of the WiX toolset is currently executing.

Here's a suggested implementation:

Variable Value
$(sys.WIX_VERSION) 3.10.1823.0
$(sys.WIX_MAJORVERSION) 3
$(sys.WIX_MINORVERSION) 10
$(sys.WIX_BUILDVERSION) 1823
$(sys.WIX_UPDATEVERSION) 0

Originally opened by david

wixbot commented 9 years ago

ps. I'd be happy to create a PR for this if the idea is approved.

Originally posted by david

wixbot commented 9 years ago

You can do this at a file level already using Wix/@RequiredVersion. We don't understand the use case, though; can you provide a concrete example?

wixbot commented 9 years ago

The particular scenario I'm looking at relates to the now deprecated Action="createAndRemoveOnUninstall" attribute. This generates a warning in more recent versions of Wix, but didn't in earlier ones. And if you build with 'warnings as errors' then that fails the build.

I'd like to be able to conditionally include the original line for older versions of Wix, but switch to a newer line for more recent ones. (In my situation most machines are running the old version of Wix, and it will take some organising to upgrade them all, but for testing out VS2015, my own machine is running 3.10)

Originally posted by david

wixbot commented 9 years ago

FYI - I had a similar problem when I moved from 3.8 to 3.9 (if I recall because there was a change to util:ProductSearch). My 3.8 code as I recall failed to compile in 3.9. I was using 3.9 in my dev system but the build box needed to stay at 3.8 for a period of time. To address this I used MSBuild to detect the version of WiX and set a MSBuild property which I used with: <CompilerAdditionalOptions> $(CompilerAdditionalOptions) -dmyWixVer="$(myWixVer)" </CompilerAdditionalOptions>

And then in the wxs I used preprocessor for $(var.myWixVa) to build code compatible with 3.8 on the build box and compatible with 3.9 on my system.  When I updated the build box to 3.9 I tossed all of this code.

Originally posted by phogland

wixbot commented 9 years ago

I can see it being useful if you have BA extensions or customisations as it would allow the correct one to be loaded based on which version of WiX is installed. For example, I would like to trial 3.10 and an updated ExtBA but my build machine is still 3.9.

Originally posted by neilsl

wixbot commented 9 years ago

OK, sounds reasonable. We've added new warnings but everything else is compatible.