Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WIX Installer: Cannot set more than one appSettings node

I have the following in a wix installer:

<util:XmlFile Id="leID4" File="[INSTALLFOLDER]app.config" Sequence="5"
                      Action="setValue" ElementPath="/configuration/appSettings/add[\[]@key='JobProcessorTimerInterval'[\]]/@value" Value="60000" Permanent="yes" />

<util:XmlFile Id="leID5" File="[INSTALLFOLDER]app.config" Sequence="6"
                      Action="setValue" ElementPath="/configuration/appSettings/add[\[]@key='FromEmail'[\]]/@value" Value="[FROMEMAIL]" Permanent="yes" />

This is my app.config file:

<configuration>
<appSettings>
    <add key="FromEmail" value="[email protected]" />
    <add key="JobProcessorTimerInterval" value="60000"/>
</appSettings>
</configuration>

When I run the installer I get this message:

enter image description here

I have tried multiple paths but I can't seem to get this working. Can anyone see where I am going wrong?

like image 862
Paul MC2 Avatar asked May 27 '26 16:05

Paul MC2


1 Answers

Can you try the one below? The WIX documentation states that:

"setValue - Sets a value in the element specified in the ElementPath. If Name is specified, and attribute with that name is set to the value specified in Value. If Name is not specified, the text value of the element is set. Value is a required attribute if setValue is the action specified."

    <util:XmlFile Id="leID4" 
                        File="[#filename]" 
                        Sequence="5"
                        Action="setValue" 
                        ElementPath="//appSettings/add[\[]@key='JobProcessorTimerInterval'[\]]" 
                        Name="value" 
                        Value="60000" 
                        Permanent="yes" 
                        SelectionLanguage="XPath" />

    <util:XmlFile Id="leID5"
                        File="[#filename]" Sequence="6"
                        Action="setValue" 
                        ElementPath="//appSettings/add[\[]@key='FromEmail'[\]]" 
                        Name="value" 
                        Value="[FROMEMAIL]" 
                        Permanent="yes" 
                        SelectionLanguage="XPath" />

<File Id="filename" Name="xmlfiletest" Source="..\\xmlfile1.xml">
          </File>

filename is the ID attribute of the FILE element in your WIX for the app.config file.

like image 154
Isaiah4110 Avatar answered May 30 '26 04:05

Isaiah4110



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!