tags:

views:

778

answers:

2

I'm trying to make an install using WiX and I need to modify a configuration file (not XML or INI) with entries that a customized WiX dialog.

Is there a good way to do this? Do I need to make a VB script custom action, perhaps?

Below is the relevant bits of the wxs file:

   <Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="ProgramFilesFolder">
         <Directory Id="INSTALLLOCATION" Name="MyApp">
             <Component Id="ap_cfg" KeyPath="yes" Guid="...">
                 <File Id="CONFIGFILE" Source="myConfig.cfg" />
              </Component>
         </Directory>
      </Directory>
   </Directory>
+1  A: 

There is no build in Search & Replace construct in Wix, you will need to write a custom action.
I suggest that instead of using VBScript you will use DTF which will enable you to write the custom action in .net and debug it under Visual Studio.

Shay Erlichmen
+1  A: 

So you want to install a config file, by modify it dynamically during installation?

You're better off writing a custom action in native/unmanaged code like C++ that reads the various MSI properties and writes them out to your config file. Don't install the file with a keypath at any rate, otherwise as soon as it's modified it won't match the original hash and will be repaired. Better to just write out the "default" config from the binary table or something and then modify it, that way windows installer doesn't care what you do with it.

I wouldn't advise using managed code for your custom actions either, use C++ and you'll save yourself a lot of headaches down the road. There are a few very good examples in the WiX toolset source to get you started.

Finally, before you even think about using VBScript go and read why VBScript (and Jscript) MSI CustomActions suck.

sascha