tags:

views:

11

answers:

1

I have a wix installer that will install an XML file and then modify it. Installation works great. Today, I needed to add a couple of nodes to this XML file. So I modified the original file and then added some additional instructions to wix to assign these items values.

Well, I get an error every time saying that it cannot find the node. I look and see what file it has in the directory and it still has the older file that did not have the node. How can I tell it to replace the XML file first and then modify it? I don't want to use "CreateElement" because I don't know how to not create an element if it exists already (haven't tried it, so maybe it'd work). Besides, I want my XML file to be the definition of the configuration.

Here's a sample of my XML:

      <Component Id="MyProgExeConfigComponent" Guid="*">
    <File
      Id="MyProgExeConfig"
      Name="MyProg.exe.config"
      DiskId="1"
      Source="../Published/MyProg/MyProg.exe.config"
      PatchWholeFile="yes"
      KeyPath="yes"/>
    <util:XmlFile
      Id="MyProgExeConfigUser"
      Action="setValue"
      Permanent="yes"
      File="[INSTALLLOCATION]\MyProg.exe.config"
      ElementPath="/configuration/appSettings/add[\[]@key='UserName'[\]]"
      Name="value"
      Value="[USER]"/>
    <util:XmlFile
      Id="MyProgExeConfigPassword"
      Action="setValue"
      Permanent="yes"
      File="[INSTALLLOCATION]\MyProg.exe.config"
      ElementPath="/configuration/appSettings/add[\[]@key='Password'[\]]"
      Name="value"
      Value="[PASSWORD]" />

Any ideas?

+1  A: 

Windows Installer is probably not overwriting the file because you have INSTALLMODE=omus and the XML's create and modification dates are different.

Is the XML file the key file of it's own component? If so, try using the File@DefaultVersion attribute to trick Windows Installer into thinking the new file has a version # ( we call this 'Version Lying" when googling ) and therefore trumps the non-versioned file. Your file will be overwritten and then your XML updates can be applied from there.

Christopher Painter
Sweet! That worked. Thanks again, Chris. Now do I need to increment this version every time I make a change to the XML file?
Jason Thompson
No. I usually just set the version to upper bound ( 65535.65535.65535.65535 ) or similar and you are fine. The real deployed file will never have a version number.
Christopher Painter