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.

Tuesday, May 4, 2010

WiX: How to skip LicenseAgreementDlg – more elegant solution

According to WiX documentation if you want to remove the LicenseAgreementDlg from the WixUI_InstallDir dialog set, you suggested to copy the full contents WixUI_InstallDir.wxs from the WiX sources to your project and than manually edit it.
It isn’t very convenient way.
There is more elegant solution I have found here:

<UI>
<UIRef Id="WixUI_InstallDir" />
<!-- skip licence dialog -->
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="2">1</Publish>
</UI>

Because of a greater value in the Order attribute new events have priority over events, which were set up in WixUI_InstallDir.wxs to redirect to license dialog.

You can use the same technique to add your own manually created dialogs to the installation sequence.

Thanks to slashh!