I am moving from a Wise Installer to WIX and am using the util:xmlfile to update a configuration xml file.
This works.
<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>
This does not work.
<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>
When the .msi executes with the first component, everything is fine. In the second version, an error is returned "Error 25531. Failed to open XML file..."
As far as I can tell the only difference is the hyphen in the file name.
Any suggestions as to what the difference might be?
The value for the
File
attribute forutil:XmlFile
tag should refer to theId
attribute for theFile
tag.In your case this would be
In your example since you use the same identifier for both the
Component
tag and theFile
tag it doesn't matter. But in general you need to use the Id for theFile
tag.To clarify, if your example used
configComponent
andconfigFile
respectively forComponent
andFile
identifiers. It would look like the following:Try using the component's id instead of hard-coding the name
instead of