Reputation: 12486
I wrote this in my WiX project file (I simplified my examples):
<?define info = R172 ?>
<?define var1="$(var.info.TargetPath)" ?>
<?define var2="$(var.info.TargetDir)" ?>
I would like the info
will be expanded by preprocessor into such variant:
<?define var1="$(var.R172.TargetPath)" ?>
<?define var2="$(var.R172.TargetDir)" ?>
But I get the error:
Undefined preprocessor variable
$(var.info.TargetPath)
.
This variant doesn't work too:
<?define var1="$(var.$(var.info).TargetPath)" ?>
<?define var2="$(var.$(var.info).TargetDir)" ?>
Also I have tried foreach
using:
<?foreach info in R172?>
<?define var1="$(var.info.TargetPath)" ?>
<?define var2="$(var.info.TargetDir)" ?>
<?endforeach?>
But I get the same problem.
Can I do the similar substitution somehow?
UPD
I.e. I want to use it for working with referenced projects through the foreach
:
<!-- The list of the names of referensed projects -->
<?define ACAD_VERSIONS=R172;R182;R190?>
<?foreach ACAD in ACAD_VERSIONS?>
<Feature Id="Feature.$(var.ACAD)" Title="$(var.ACAD)" Level="1">
<Component Id="cmp$(var.ACAD)" Guid="*" Directory="INSTALLFOLDER">
<File Id="extension.$(var.ACAD).dll" Source="$(var.$(var.ACAD).TargetPath)" KeyPath="yes"/>
</Component>
</Feature>
<?endforeach?>
Upvotes: 2
Views: 972
Reputation: 1903
Unfortunately the current version of WIX (3.10.2) doesn't appear to support what you are requesting.
Looking at the WIX source code, specifically the file src\tools\wix\PreProcessorCore.cs
from WIX310-Debug.zip downloadable from here, it doesn't look like WIX supports recursive name substitution. So you can't do $(var.$(var.something))
. Take a look at the function PreprocessString(...)
to confirm this for yourself.
You might be able to do something with <?undef ...?>
. For example:
<?define var1="$(var.item1)" ?>
<?include CommonFeature.wxs ?>
.
<?undef var1 ?>
<?define var1="$(var.item2)" ?>
<?include CommonFeature.wxs ?>
See the related WIXToolset issue: Nested preprocessor variables.
Upvotes: 1