Tuesday, May 11, 2010

WiX: The meaning of MergeRedirectFolder variable

I faced with MergeRedirectFolder in the default merge module created by Votive (when you add new WiX Merge Module Project to your solution in Visual Studio).

I’ve failed to find any information about it. Even WiX documentation completely ignores it. So I’ve carried out the investigation.

Conclusion I’ve made:
MergeRedirectFolder refers to the directory where merge module files will be put according to Product installation scenario. In other words it refers to the directory referenced by Directory element to which Merege element belongs to in Product wix scenario file.

Here is scenario of my investigation.
Two files were created: one for msi and another for msm. After that I made a reference to msm (as it is suggested in WiX documentation)

Investigation.msi.wxs:
...
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder'>
<Directory Id='MyDir' Name='Test Program'>
<Directory Id='subDir' Name=’SubDir’>
<Merge Id='MyModule' Language='1033' src= ‘Investigation.msm' DiskId='1' />
</Directory>
</Directory>
</Directory>
</Directory>
...


Investigation.msm.wxs:
...
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="MergeRedirectFolder" FileSource="." >
<Component Id="ProductComponent" Guid="27af1a85-9a01-4c79-bdeb-d73fd4bd9574">
<File Name="readme.txt" />
</Component>
</Directory>
</Directory>
...


Then builded installation finished, readme.txt was in %ProgramFiles%\MyDir\subDir\ (according to Investigation.msi.wxs)

Second time I exclude MergeRedirectFolder directory from Investigation.msm.wxs:
...
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder'>
<Directory Id='MyDir' Name='Test Program'>
<Component Id="ProductComponent" Guid="27af1a85-9a01-4c79-bdeb-d73fd4bd9574">
<File Name="readme.txt" />
</Component>
</Directory>
</Directory>
</Directory>
...


And readme.txt changed it’s location to %ProgramFiles%\MyDir\. So it was put into directory set by Investigation.msm.wxs file and ignores directory in which it should be put according to Investigation.msi.wxs.

2 comments:

Alek Davis said...

Thanks for the investigation. Saved me some time. :-)

Harshraj said...

This is helpful. Thanks for documenting this.