Search code examples
xmlwixproperties.settings

How Do I insert the INSTALLFOLDER-location into a .settings file with WiX?


As the title gives away I have huge problems inserting the custom install location INSTALLFOLDER into a .settings file. Its the the location WiX uses when doing the usual:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="ToplevelFolder" Name="blaa">
      <Directory Id="INSTALLFOLDER" Name="bluub">
       ...so on....

The good thing is that the .settings-file is written in XML though it doesn't end on .xml explicitly. Also I'm not talking about a Settings.settings-file (from the .NET environment)

This being said, I've already tried the WiX integrated XML editing extension by temporarily changing the .settings to an .xml file to insert a string (more precisly the INSTALLFOLDER-location) and afterwards renaming it back to .settings file by using the name="bla.settings" tag. Even though the building of the.msi works perfectly then, the installation itself spills out the errorcode

"Failed to open XML file, system error: -2147024786"

after about 80-90% of the installation.

I've searched everything for Days now without getting any further, so I would really appreciate some help!

PS: I've already heard that custom Actions can do the Work here to, and might even be the solution. However I'm lacking the insight of how to build one that does just precisely what I need. Again Information /Tutorials/Guids would really be appreciated!

EDIT: This is what using the extension looks like in my code:

<File Id="fil0CCD9555A0AF7A2FA45DFC80F03955CB" KeyPath="yes" Name="adtf_devenv.settings" Source="!(wix.HelpDir)\adtf-2.9.0-win64-vc100\bin\adtf_devenv.xml" />
<util:XmlFile Id="setDIR" Action="createElement" Permanent="yes" File="[#adtf_devenv.xml]" ElementPath="/[adtf:export]" Name="file" Value='Artefacts="INSTALLFOLDER\Artefacts\" name="Stadtpilot"' />

Solution

  • You could write the custom action in C# and then call that in your wix file. This is a good tutorial explaining how to write and use a custom action.

    http://blogs.msdn.com/b/jschaffe/archive/2012/10/23/creating-wix-custom-actions-in-c-and-passing-parameters.aspx