安装前 WiX 检查文件是否存在 [英] WiX Check File Exists before Install

查看:28
本文介绍了安装前 WiX 检查文件是否存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经多次看到这个问题,但似乎没有一个答案对我有用.我显然错过了一些基本的东西,但我似乎无法找出它是什么!我只用了几天 WiX,所以我对它还是很陌生.

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>

其中 INSTALLDIR 是 main.exe 所在目录的 Id,在嵌套的 Directory 标签中定义.>

Where INSTALLDIR is the Id of the directory where the main.exe should be and is defined in the nested Directory tags.

推荐答案

在用户可以通过 MSI 对话框设置安装文件夹之前执行搜索.所以这种方法不会像你想要的那样工作.

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.

如果要检查安装文件夹中的文件,我建议通过 DoAction 控制事件.此事件可由文件夹选择对话框中的下一步"按钮触发.

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.

没有为此预定义的自定义操作,因此您需要使用自定义代码编写一个.它应该是接收安装句柄的 DLL 或 VBScript.你可以在这里找到一个小教程:http://www.codeproject.com/KB/install/msicustomaction.aspx

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

这篇关于安装前 WiX 检查文件是否存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆