简体   繁体   English

WiX根据注册表值更改UI行为

[英]WiX Changing UI behavior based on registry value

The short version is that I am building an installer package, and I want the “Next” button of my welcome screen to change its behavior based on whether or not a specific registry key exists. 简短的版本是我正在构建安装程序包,并且我希望我的欢迎屏幕上的“下一步”按钮根据是否存在特定的注册表项来更改其行为。 It seems like I should be able to modify the conditions of the next button's actions to get this behavior, but so far no luck. 看来我应该能够修改下一个按钮动作的条件以获得这种行为,但到目前为止还算不上什么。 I always either get behavior A or behavior B, I have not gotten behavior that is sensitive to the registry value. 我总是得到行为A或行为B,但我没有得到对注册表值敏感的行为。

I should note that I can remove the UI completely and run the package via command line to get the desired results, but I am trying to be a little more user friendly by adding the install path dialog when appropriate. 我应该注意,我可以完全删除UI并通过命令行运行程序包以获得所需的结果,但是我尝试通过在适当时添加安装路径对话框来使用户更加友好。

In a bit more detail… 更详细一点...

I am working on installers for a series of independent, but related, class libraries. 我正在为一系列独立但相关的类库进行安装。 If we install a library on a clean box I want the installer to prompt the user for an install path, and then write this path off to the registry during the install process. 如果我们在一个干净的盒子上安装一个库,我希望安装程序提示用户输入安装路径,然后在安装过程中将此路径写到注册表中。 However if we install a library on a box which already has one of the other libraries present, I want the installer to read the registry and use the same path as the previous install. 但是,如果我们在已经有其他库之一存在的盒子上安装库,则我希望安装程序读取注册表并使用与先前安装相同的路径。

My thought process was to modify the standard WixUI_InstallDir interface to check for the registry search result and skip the InstallDirDlg if it is set. 我的想法是修改标准的WixUI_InstallDir接口,以检查注册表搜索结果,并跳过InstallDirDlg(如果已设置)。 However this does not appear to be working. 但是,这似乎不起作用。 Here are some snips from the XML: 这是XML的一些片段:

<Property Id="FOOPATH">
  <RegistrySearch Id="PathSet" Type="directory" Root="HKLM" Key="Software\Foo" Name="InstallPath"></RegistrySearch>
</Property>
<Property Id="PATHSET">
  <RegistrySearch Id="PathSet" Type="directory" Root="HKLM" Key="Software\Foo" Name="InstallPath"></RegistrySearch>
</Property>

<Directory Id="FOOPATH" Name="Foo">
  <Component Id="FooPathReg" Guid="Some Guid">
    <RegistryKey Root="HKLM" Key="Software\Foo" Action="createAndRemoveOnUninstall">
      <RegistryValue Name="InstallPath" Type="string" Value="[FOOPATH]" KeyPath="yes"></RegistryValue>
    </RegistryKey>
  </Component>
</Directory>

<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg">NOT Installed AND NOT PATHSET</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg">NOT Installed AND PATHSET</Publish>

If my publish conditions are using the PATHSET property (as shown) then I always get the install directory dialog, if I switch them to use the FOOPATH property then I never get the dialog. 如果我的发布条件使用的是PATHSET属性(如图所示),那么我将始终显示安装目录对话框,如果将它们切换为使用FOOPATH属性,则将永远不会显示该对话框。 I have also tried playing with the InstallUISequence and it does not seem to matter how early I schedule the AppSearch action, I still get the same result. 我也尝试过使用InstallUISequence,看来安排AppSearch操作多早无关紧要,但仍然得到相同的结果。

Is there something simple I am missing? 有什么简单的我想念的吗? Or do I need to take another approach on this? 还是我需要采取另一种方法?

  1. Check a verbose log to see if the properties are set as you expect. 检查详细日志以查看是否按预期设置了属性。
  2. Use Orca to see if the ControlEvent is as you expect. 使用Orca查看ControlEvent是否符合预期。 UI is additive, so you have to take extra steps when you want to replace the stock UI. 用户界面是附加的,因此当您要替换库存用户界面时,您必须采取额外的步骤。 For example, see http://neilsleightholm.blogspot.com/2008/08/customised-uis-for-wix.html . 例如,请参阅http://neilsleightholm.blogspot.com/2008/08/customised-uis-for-wix.html

Ok this turned out to be one of those brain dead moments where I missed something in my testing process. 好的,这原来是我在测试过程中遗漏某些东西的大脑死亡时刻之一。 I am filling in the details of why it was failing in the hope that it saves someone else some of the frustration I have experienced while working on it. 我正在填写它为什么失败的详细信息,希望它可以使其他人在进行此开发时遇到的挫败感免于受挫。

First it is important to know that I was not actually testing multiple packages, I was trying to get my base structure worked out with the first package, then apply it to the rest when I thought I had it fairly close, this was to help reduce the number of changes I needed to replicate across the group of packages. 首先,重要的是要知道我并未真正测试多个软件包,我试图让我的基础结构与第一个软件包一起工作,然后在我认为我已经相当接近的情况下将其应用于其余软件包,这是为了帮助减少我需要在一组软件包之间复制的更改数量。 To do this I was manually adding the registry entry in question, prior to running the package, there by simulating a prior install. 为此,我在运行程序包之前通过模拟先前的安装来手动添加有问题的注册表项。

What I neglected to do was actually create the directory referenced by the registry entry. 我忽略的实际上是创建注册表项引用的目录。 I was walking through the process with a co-worker, and in the course of explaining it I noticed this section of the log: 我正在与一位同事一起浏览整个过程,在解释过程中,我注意到了日志的这一部分:

Action start 8:26:16: AppSearch.
MSI (c) (BC:D4) [08:26:16:505]: Note: 1: 2262 2: Signature 3: -2147287038 
MSI (c) (BC:D4) [08:26:16:506]: Note: 1: 2262 2: Signature 3: -2147287038 
MSI (c) (BC:D4) [08:26:16:507]: Note: 1: 2262 2: Signature 3: -2147287038 
MSI (c) (BC:D4) [08:26:16:507]: PROPERTY CHANGE: Adding NETFRAMEWORK35 property. Its value is '#1'.
Action ended 8:26:16: AppSearch. Return value 1.

And it occurred to me to try creating the directory referenced by the registry value as well as the registry value itself. 我想到尝试创建由注册表值以及注册表值本身引用的目录。 Once the directory was there, everything started working properly. 一旦目录存在,所有内容就会开始正常工作。

Apparently when you tell the RegistrySearcher that the value is a directory, it only sets the value into the property when said directory actually exists. 显然,当您告诉RegistrySearcher该值是一个目录时,仅当该目录实际存在时才将值设置为属性。 This detail never came up in my searches on the topic, and is not clear in the documentation I have found, though in retrospect I can see where it is implied. 尽管在回溯时我可以看到它的隐含含义,但是在我对该主题进行搜索时,从来没有出现过这个细节,并且在找到的文档中也不清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM