开发者

WiX Check File Exists before Install

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 开发者_JAVA技巧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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜