0

I'm trying to create an installer authored in WiX, and while I think my code is correct based on other examples that I've found, the XML file is not being updated on installation. I'm trying to use a value that the user inputs into the installer UI to update the value of a key-value pair in the config file. The pair already exists in the file with a default value set, so I would like the user to be able to overwrite that value from the installer UI. I've looked at questions here with similar issues, but none of those fixes seem to work for me.

Here is a code snippet of what I have:

<Component>
  <File Source="$(var.DIR)\file.exe.config" />
  <util:XmlFile
    Id="ServerNameUpdate"
    File=[INSTALLFOLDER]file.exe.config
    Action="setValue"
    ElementPath="/configuration/appSettings/add[\[]@key='ServerURL'[\]]/@value"
    Name="value"
    Value="http://[SERVER]/
    Sequence="1" />
</Component>

I'm not getting any errors, but my config file is not changing on installation. the XML line should look like this:

<add key='ServerURL' value='http://[SERVER]/' />

Even if I use a hardcoded Value, the value is not changed. Is there something wrong with my code?

1 Answer 1

0

Try doing this:

<File Id="FileConfigPath" KeyPath="yes" Source="[INSTALLFOLDER]file.exe.config" Vital="yes"  />

<util:XmlFile Id="ServerNameUpdate"
      Action="setValue"
      Permanent="yes"
      ElementPath="//appSettings/add[\[]@key='ServerURL'[\]]/@value"
      File="[#FileConfigPath]"
      Value="http://[SERVER]/"
      SelectionLanguage="XPath" 
      Sequence="1"
      />
Sign up to request clarification or add additional context in comments.

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.