I have seen this question asked many times but none of the answers seem to work for me. I'm obviously missing something elementary, but I can't seem to find out what it is! I've only been using WiX for a couple of days so I'm still very new to it.
Basically, I've built a plug in to an existing product, and I want to check that the product is installed before allowing my plug in to install. I think the simplest way is to check the main executable is in the correct directory.
My relevant code so far:
<Property Id="FILEEXISTS">
<DirectorySearch Id="CheckFileDir" Path="INSTALLDIR" Depth="0">
<FileSearch Id="CheckFile" Name="main.exe" />
</DirectorySearch>
</Property>
<Condition Message="File does exist.">NOT FILEEXISTS</Condition>
Where INSTALLDIR
is the Id
of the directory where the main.exe should be and is defined in the nested Directory
tags.
Searches are executed before the user can set an installation folder through the MSI dialogs. So this approach won't work the way you want.
If you want to check for a file in the installation folder, I suggest an UI custom action executed through a DoAction control event. This event can be triggered by the Next button on your folder selection dialog.
There are no predefined custom actions for this, so you will need to write one with custom code. It should be a DLL or VBScript which receives the installation handle. You can find a small tutorial here: http://www.codeproject.com/KB/install/msicustomaction.aspx