0

I need to define a variable in the Pre-Build event of my Visual Studio project to be used later by Wix.

Since the build event allows me to execute commands, my idea was to add a new environment variable (I've tried both set and setx):

setx AppIcon MyIcon.ico

And then I've tried to read it in my Main.wxs file:

<Icon Id="AppIcon" SourceFile="$(sys.CURRENTDIR)..\ApplicationIcon\$(env.AppIcon)" />

But of course, I got Undefined preprocessor variable '$(env.AppIcon)'.

Any other ideas on how to accomplish this? Is it possible?

fsinisi90
  • 1,138
  • 1
  • 16
  • 45
  • 1
    One idea is to change your WiX source to reference a variable from an include file. Then in your prebuild event, call a utility (that you write) that can set the appropriate value in the include file. Here is an example on using an include file: https://stackoverflow.com/a/12973764/1202501 – BryanJ Oct 30 '19 at 20:03
  • Thanks, that should work. Although it's not difficult, I was expecting that there was a simpler way and I was missing it. – fsinisi90 Oct 30 '19 at 20:12

0 Answers0