TL;DR:为什么我需要在这个条件组件中使用一个空 <CreateFolder/>
元素才能使其工作?
我正在为内部应用程序组装一个简单的基于 WiX 的安装程序。此安装程序需要部署一个标准配置文件(一个普通的 .NET.config
文件),然后使用传递给msiexec
命令行的属性对其进行自定义。
其中一项自定义是仅在定义了 RUNTIME 属性时才创建特定的应用程序设置。这是 WiX 组件:
<Component Id="C.Rbnz.Fsis.CollectionPeriodService.exe.config.runtime"
Guid="*">
<Condition>
<![CDATA[RUNTIME]]>
</Condition>
<CreateFolder/>
<util:XmlFile Id="X.Runtime.1"
Action="createElement"
ElementPath="/configuration/appSettings"
File="[#F.Rbnz.Fsis.CollectionPeriodService.exe.config]"
Name="add"
Sequence="2"/>
<util:XmlFile Id="X.Runtime.2"
File="[#F.Rbnz.Fsis.CollectionPeriodService.exe.config]"
ElementPath="/configuration/appSettings/add[\[]not(@key)[\]]"
Action="setValue"
Name="key"
Value="RunTime"
Sequence="3"/>
<util:XmlFile Id="X.Runtime.3"
File="[#F.Rbnz.Fsis.CollectionPeriodService.exe.config]"
ElementPath="/configuration/appSettings/add[\[]@key='RunTime'[\]]"
Action="setValue"
Name="value"
Value="[RUNTIME]"
Sequence="4"/>
</Component>
这就像我想要的那样工作 - 如果在命令行上指定 RUNTIME msiexec
,则创建新元素;如果没有,什么都不会发生。
为什么我必须<CreateFolder/>
在这个组件中有空?
当我试图让它工作时,我发现了“ Wix Condition Statement ”,它显示了一个工作组件,但没有解释为什么<CreateFolder/>
是必要的。
删除<CreateFolder/>
给了我这个错误:
ICE18:组件的 KeyPath:“C.Rbnz.Fsis.CollectionPeriodService.exe.config.runtime”是目录:“INSTALLDIR”。目录/组件对必须列在 CreateFolders 表中。
我敢肯定,一旦您知道它的含义,就会提供很多信息。