Dealing with env specific files using WIX

Go To


I am in the process of migrating all my projects one by one from Installshield to Wix and I would like to find out the best way to deal with env specific files.

Our current process is: Using Installshield we create a base MSI and a Transform file which would install the base MSI and a directory structure with files present in the current directory. Ofcourse in my source control, I have separate config files for different environments and my Deployment script picks up the right set of files and puts them in a staging location.

For example, Current dir looks like as follows:





sample.msi gets installed and the above directory structure gets copied to the target location. During Uninstall the directory structure gets removed as well.

I tried to recreate this behavior using CopyFile element but during uninstall the copied files stay and do not get removed. Is there another way to achieve this?

I understand the way we do our packaging might not be the best way to get around our requirements. If someone has a better way to do this, please let me know.

I am still very new to Wix and I haven't looked at any of the wix extensions so wouldn't know what else is out there.

As always, any help is greatly appreciated.

2012-04-03 20:44
by soothsayer


Do these files really have to be seperate from the msi? Using wix you could put them all into the msi and install them based on certain conditions like settings properties or using a custom action. Doing it that way should make it rather easy to let the msi create the directories and copy the files, and also remove them when uninstalling.

Conditions would work like this:

<Component Id='MyComponent' Guid='PUT-GUID-HERE'>
  <Condition><![CDATA[YOUR-PROPERTY = "SOME_STRING"]]></Condition>
 <File Id='readme' Name='readme.txt' DiskId='1' Source='readme.txt' />

A CustomAction in Wix can be a .net dll, the manual explains how this is done here: Adding Custom Actions

IF you have the WIX Toolkit installed you just need to create a Custom Action Project.

2012-04-03 22:40
by shriek
yup. This would be a way to do it. I just wanted to know if there was another way instead of embedding the files in the MSI - soothsayer 2012-04-05 15:37
Well, the only other way would be to write a CustomAction that gets those files from the network and places them in the directory and remove them with the same CustomAction when the application gets uninstalled - shriek 2012-04-05 16:09
@Hitesh Savla: edited my answe - shriek 2012-04-05 16:13