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
I suppose you miss the square brackets [] around the INSTALLDIR in @Path. Also, the @Depth=0 looks suspicious, just omit this attribute for a plain search, it should default to 1 and this is what you normally need to look for a file in a directory.
Hope that helps, but to be strict, your question doesn't contain the real question. It is difficult to understand whether you are getting any error, or the condition just doesn't work...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With