The syntax for ifdef is <?ifdef MyVariable?>, not <?ifdef $(var.MyVariable)?>.
So, it would appear that ifdef only checks for preprocessor variables and not
environment variables. Even if you had <?ifdef $(env.PATH)?> or any other
existing environment variable, the ifdef wouldn't be working as you'd expect it
to.
Your other approach, <?if $(env._BuildArch)!=null?> won't work because the
preprocessor doesn't know about 'null' (that's what ifdef is for). I don't
think it would be unreasonable to log a feature request on sourceforge to have
an undefined environment variable resolve to an empty string instead of a
compiler error.
A possible solution for you would be evaluate _BuildArch on the command line
and pass it as a preprocessor variable to candle.
1. You'll want to use a command line like:
Candle.exe source.wxs -out out.wixobj -dBuildArchVar=%_BuildArch%
2. And sse authoring similar to this:
<?if $(var.BuildArchVar)="x86"?>
<?define _X86_ = "yes"?>
<?endif?>
If %_BuildArch% is defined in your environment, it will be resolved before it
gets passed to candle. If it is not defined in your environment, it will get
resolved to the string "%_BuildArch%" which is fine because the <?if?> won't
evaluate to true.
Hope this helps.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of zhisheng huang
Sent: Monday, March 24, 2008 2:38 PM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] how does preprocessor suppose to work
Hi,
When environment variable _BuildArch is not defined. The following code fails
with "Undefined preprocessor variable '$(env._BuildArch)'".
<?ifdef $(env._BuildArch)?>
<?warning You should not see this?>
<?if $(env._BuildArch) != null and $(env._BuildArch) = "x86" ?>
<?define _X86_ = "yes"?>
<?endif?>
<?endif?>
Actually I think I should use <if $(env._BuildArch) != null> for the first
statement. But I got "Undefined preprocessor variable '$(env._BuildArch)'" for
that too.
The warning text "You should not see this" is NOT displayed, which means the
the first statement is evaluated false. Then why is the <?if?> inside that
<?ifdef> is evaluated?
How can I check if an environment variable is defined or not?
I am using Wix 3.0. Thanks for any comment or suggestion!
Zhisheng
________________________________
Test your Star IQ Play
now!<http://club.live.com/red_carpet_reveal.aspx?icid=redcarpet_HMTAGMAR>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users