我正在从 Wise Installer 迁移到 WIX,并使用 util:xmlfile 更新配置 xml 文件。
这有效。
<Component Id="config" Guid="*">
<File Id="config" Source="..\Source\Desktop\prodconfig.xml" KeyPath="yes" Vital="yes" />
<util:XmlFile
Id="_PORT_" File="[INSTALLDIR]prodconfig.xml"
Action="setValue"
Name="Port" Value="[PORT]"
ElementPath="//Configuration/CommConnectionPools/CommConnectionPool"
Sequence='1' />
</File>
</Component>
这是行不通的。
<Component Id="config" Guid="*">
<File Id="config" Source="..\Source\Desktop\prod-config.xml" KeyPath="yes" Vital="yes" />
<util:XmlFile
Id="_PORT_" File="[INSTALLDIR]prod-config.xml"
Action="setValue"
Name="Port" Value="[PORT]"
ElementPath="//Configuration/CommConnectionPools/CommConnectionPool"
Sequence='1' />
</File>
</Component>
当 .msi 与第一个组件一起执行时,一切正常。在第二个版本中,返回错误“Error 25531. Failed to open XML file...”
据我所知,唯一的区别是文件名中的连字符。
有什么不同的建议吗?
最佳答案
尝试使用组件的 ID 而不是硬编码名称
[#config] //which will refer to the File Id
代替
[INSTALLDIR]prod-config.xml
关于xml - WIX 实用程序 :xmlfile File name is Source attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19796877/