Wix:如何在自定义安装位置中执行DirectorySearch [英] Wix: How to do a DirectorySearch in a custom installation location
问题描述
我想检测用户在GUI中选择的自定义安装位置中是否已经存在目录.我尝试了以下方法:
I would like to detect if a directory already exists in a custom installation location selected by the user in the GUI. I tried the following:
<Property Id="DIRECTORY_PATH">
<DirectorySearch Id="DirectorySearch" Path="[INSTALLDIR]\MyDirectory" />
</Property>
但是这不起作用,因为DirectorySearch发生在AppSearch期间.当稍后在InstallDirDlg中设置INSTALLDIR时.由于未为AppSearch及时设置INSTALLDIR,因此DIRECTORY_PATH错误地设置为"\ MyDirectory".
But this doesn't work because the DirectorySearch is happening during AppSearch. While INSTALLDIR is set later during InstallDirDlg. Since INSTALLDIR is not set in time for AppSearch, DIRECTORY_PATH is incorrectly set to "\MyDirectory".
当尝试通过InstallUISequence和InstallExecuteSequence进行AppSearch时,我尝试进行更改,但它只会让AppSearch在CostInitialize之前出现,而不是以后.
I tried to change when AppSearch happens with InstallUISequence and InstallExecuteSequence, but it will only let AppSearch come before CostInitialize, no later.
那么如何在用户选择的INSTALLDIR位置进行目录搜索?
So how do I do a directory search at the user selected INSTALLDIR location?
推荐答案
如果只需要等待用户的选择来验证该目录,则DirectorySearch不会为您完成这项工作.您必须在用户选择INSTALLDIR之后,例如在Next单击InstallDirDlg时立即编写设置属性"自定义操作.
If you only have to wait for the user's choice to verify that directory, then DirectorySearch won't do the job for you. You'll have to author a "set property" custom action right after the user chooses INSTALLDIR, for instance, on a Next click of InstallDirDlg.
更新.所以,我的意思基本上是:
UPDATE. So, I mean basically the following:
- 当用户进入设置的InstallDirDlg时,他/她将选择目录,该目录将置于INSTALLDIR属性中
- 然后对话框InstallDirDlg应该在下一步"按钮上触发自定义操作
- 此自定义操作应获取INSTALLDIR属性的值,并进行简单的文件系统检查INSTALLDIR是否包含MyDirectory
- 如果是,则将DIRECTORY_PATH属性设置为必要的值,例如
session["DIRECTORY_PATH"] = session[INSTALLDIR] + "\MyDirectory";
- 否则,未设置DIRECTORY_PATH(您可以在任何条件下通过检查
NOT DIRECTORY_PATH
来使用此事实)
- when the user gets to the InstallDirDlg of your setup, he/she selects the directory, which is put to the INSTALLDIR property
- the dialog InstallDirDlg should then trigger a custom action on Next button
- this custom action should get the value of INSTALLDIR property, and do a simple file system check whether INSTALLDIR contains MyDirectory
- if it does, the DIRECTORY_PATH property is set to the necessary value, e.g.
session["DIRECTORY_PATH"] = session[INSTALLDIR] + "\MyDirectory";
- otherwise, DIRECTORY_PATH is not set (and you can use this fact in any condition by checking
NOT DIRECTORY_PATH
)
希望它变得更清晰
这篇关于Wix:如何在自定义安装位置中执行DirectorySearch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!