6

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?

3
  • 1
    community.sharpdevelop.net/forums/t/4316.aspx something related Commented Nov 5, 2013 at 22:53
  • I did not try out your specific scenario but looks like it could be a bug within the WIX source code. Commented Nov 6, 2013 at 15:30
  • are you installing on a network or local drive? Commented Feb 16, 2014 at 1:33

2 Answers 2

9

Try using the file's id instead of hard-coding the name

[#config] //which will refer to the File Id

instead of

[INSTALLDIR]prod-config.xml
Sign up to request clarification or add additional context in comments.

2 Comments

That did it! I know comments that say "Thanks" aren't supposed to be written, but I would not have thought of that as being the difference so... thanks a million. It makes sense since hyphens aren't permitted in IDs.
Chris, in your answer you state alternately that the File attribute should use the Component's Id and the File's Id. The Component's Id didn't but the File's Id does.
0

The value for the File attribute for util:XmlFile tag should refer to the Id attribute for the File tag.

In your case this would be

<Component Id="config" Guid="*">
  <File Id="config" Source="..\Source\Desktop\prod-config.xml" KeyPath="yes" Vital="yes" />
    <util:XmlFile 
      Id="_PORT_" File="[#config]"  
      Action="setValue" 
      Name="Port" Value="[PORT]" 
      ElementPath="//Configuration/CommConnectionPools/CommConnectionPool" 
      Sequence='1' />
  </File>
</Component>

In your example since you use the same identifier for both the Component tag and the File tag it doesn't matter. But in general you need to use the Id for the File tag.

To clarify, if your example used configComponent and configFile respectively for Component and File identifiers. It would look like the following:

<Component Id="configComponent" Guid="*">
  <File Id="configFile" Source="..\Source\Desktop\prod-config.xml" />
    <util:XmlFile 
      Id="_PORT_" File="[#configFile]"  
[snip]
     />
  </File>
</Component>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.