3

In my installer project (WiX), I define a preprocessor variable like on the Build tab of the properties pages like so:

Version=1.1.0.0

For the sake of argument, let's say I can just as easily define it as a variable instead of a preprocessor variable.

My goal is thus: I would like to use this variable in the installer output name:

Me.Common_$(Version)

The above, of course, doesn't work - the variable referenced isn't found, so the actual output ends up being Me.Common_.msi. Is there a way to use a user-defined variable in this context?


Another viable option would be to rename the MSI file in the post-build events. However, I still can't access the variable here.

ren "!(TargetPath)" "$(TargetName)_$(Version)$(TargetExt)"

A solution to either of these methods would work for me.

zimdanen
  • 5,508
  • 7
  • 44
  • 89
  • This SO post should help: http://stackoverflow.com/questions/12191502/include-majorversion-etc-in-filename-outputname-when-building-msi-file-wix-pr – BryanJ Nov 21 '12 at 19:12
  • @BryanJ: It would be ideal not to have to crack open the wixproj file every time I need to update the version. I'd like to change it in the UI and have it transfer. – zimdanen Nov 21 '12 at 19:45

2 Answers2

3

Find/add these in your .wixproj file, under first PropertyGroup node:

<Version Condition=" '$(Version)' == ''">1.1.0.0</Version>
<OutputName>My.Common_$(Version)</OutputName>

then, when you compile you can pass Version with "/p" switch, i.e.:

msbuild <your.wifproj> /p:Version=1.1.2.0 /t:rebuild
MarcusUA
  • 394
  • 3
  • 14
0

I'm not sure how you would do that, by just using WIX.

I would try to use MSBuild and Target Builds

Have a look at my post on SO, for passing params to MSBuild

Community
  • 1
  • 1
CheGueVerra
  • 7,849
  • 4
  • 37
  • 49