我在我的WiX项目文件中写了这个(我简化了我的例子):
<?define info = R172 ?>
<?define var1="$(var.info.TargetPath)" ?>
<?define var2="$(var.info.TargetDir)" ?>
我希望预处理器将info
扩展为这样的变体:
<?define var1="$(var.R172.TargetPath)" ?>
<?define var2="$(var.R172.TargetDir)" ?>
但我收到错误:
未定义的预处理器变量
$(var.info.TargetPath)
。
此变体也不起作用:
<?define var1="$(var.$(var.info).TargetPath)" ?>
<?define var2="$(var.$(var.info).TargetDir)" ?>
我也试过foreach
使用:
<?foreach info in R172?>
<?define var1="$(var.info.TargetPath)" ?>
<?define var2="$(var.info.TargetDir)" ?>
<?endforeach?>
但是我遇到了同样的问题。
我能以某种方式进行类似的替换吗?
UPD
即。我想通过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?>
答案 0 :(得分:1)
不幸的是,当前版本的WIX(3.10.2)似乎并不支持您的要求。
查看WIX源代码,特别是可从here下载的WIX310-Debug.zip中的文件|>!
,它看起来不像WIX支持递归名称替换。所以你不能src\tools\wix\PreProcessorCore.cs
。请查看函数$(var.$(var.something))
以自行确认。
您可以使用PreprocessString(...)
执行某些操作。例如:
<?undef ...?>
请参阅相关的WIXToolset问题:Nested preprocessor variables。