Wix:如何在自定义安装位置进行 DirectorySearch

发布于 2024-12-03 10:03:36 字数 534 浏览 1 评论 0原文

我想检测用户在 GUI 中选择的自定义安装位置中是否已存在目录。我尝试了以下操作:

<Property Id="DIRECTORY_PATH">
  <DirectorySearch Id="DirectorySearch" Path="[INSTALLDIR]\MyDirectory" />
</Property>

但这不起作用,因为 DirectorySearch 是在 AppSearch 期间发生的。而 INSTALLDIR 是稍后在 InstallDirDlg 期间设置的。由于未及时为 AppSearch 设置 INSTALLDIR,因此 DIRECTORY_PATH 被错误地设置为“\MyDirectory”。

我尝试更改当 AppSearch 与 InstallUISequence 和 InstallExecuteSequence 一起发生时,但它只会让 AppSearch 在 CostInitialize 之前出现,不会更晚。

那么如何在用户选择的 INSTALLDIR 位置进行目录搜索呢?

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>

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".

I tried to change when AppSearch happens with InstallUISequence and InstallExecuteSequence, but it will only let AppSearch come before CostInitialize, no later.

So how do I do a directory search at the user selected INSTALLDIR location?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心房敞 2024-12-10 10:03:36

如果您只需等待用户选择来验证该目录,那么 DirectorySearch 将无法为您完成这项工作。您必须在用户选择 INSTALLDIR 后立即编写“设置属性”自定义操作,例如,在下一步单击 InstallDirDlg 时。

更新。所以,我的意思基本上如下:

  • 当用户到达安装程序的 InstallDirDlg 时,他/她选择目录,该目录被放入 INSTALLDIR 属性中,
  • 然后对话框 InstallDirDlg 应该在“下一步”按钮上触发自定义操作,
  • 此自定义操作应该得到INSTALLDIR 属性的值,并执行一个简单的文件系统检查 INSTALLDIR 是否包含 MyDirectory
  • 如果包含,则将 DIRECTORY_PATH 属性设置为必要的值,例如session["DIRECTORY_PATH"] = session[INSTALLDIR] + "\MyDirectory";
  • 否则,DIRECTORY_PATH 未设置(并且您可以通过检查 NOT DIRECTORY_PATH

希望它能让它更清楚。

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:

  • 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)

Hope it makes it clearer.

绅刃 2024-12-10 10:03:36

希望这会对您有所帮助。

如果您在注册表中存储了以前安装的INSTALLDIR,则可以获取并搜索它。在安装 UI 序列中,安装位置将指向先前的位置。

<!-- Set previous install location, if available -->
<Property Id="INSTALLDIR" Secure="yes">
  <RegistrySearch Id="InstallRootRegistry"
                  Type="raw"
                  Root="HKLM"
                  Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
                  Name="INSTALLDIR" />
</Property>

<!-- The property WIXUI_INSTALLDIR must be set for the UI to know which directory to use as default -->
<Property Id="WIXUI_INSTALLDIR"
          Value="INSTALLDIR"  Secure="yes"/>

Hope this will help you.

If you have stored the INSTALLDIR of previous installation in registry, you can get it and search for it. In the Install UI sequence the Installtion location will point to previous location.

<!-- Set previous install location, if available -->
<Property Id="INSTALLDIR" Secure="yes">
  <RegistrySearch Id="InstallRootRegistry"
                  Type="raw"
                  Root="HKLM"
                  Key="SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
                  Name="INSTALLDIR" />
</Property>

<!-- The property WIXUI_INSTALLDIR must be set for the UI to know which directory to use as default -->
<Property Id="WIXUI_INSTALLDIR"
          Value="INSTALLDIR"  Secure="yes"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文