WiX - 从上一个对话框设置属性
Posted
技术标签:
【中文标题】WiX - 从上一个对话框设置属性【英文标题】:WiX - Set Property From Previous Dialog 【发布时间】:2019-06-14 16:49:27 【问题描述】:我看到 WiX 的一些奇怪行为让我头疼。
业务规则:允许用户覆盖安装目录。允许用户覆盖配置文件安装目录(使用安装目录作为之前设置的默认路径)。
Dialog流程如下(标记如下):WelcomeDlg->InstallDirDlg->LogConfigDlg
<UI Id="MyWixUI_InstallDir">
<UIRef Id="WixUI_InstallDir" />
<!--Add default dialogs: BrowseDlg, DiskCostDlg, InstallDirDlg, InvalidDirDlg, LicenseAgreementDlg, WelcomeDlg, VerifyReadyDlg, etc.-->
<!--<DialogRef Id="AppConfigDlg" />-->
<!-- Override the next and back buttons on the WelcomeDlg and InstallDirDlg to skip the License agreement page of the installer -->
<Publish Dialog="WelcomeDlg" Control="Next" Event="DoAction" Value="regSetINSTALLDIR" Order="1">PREVIOUSINSTALLFOLDER</Publish>
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallDirDlg" Order="2">NOT Installed</Publish>
<Publish Dialog="InstallDirDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg" Order="1">1</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="SetLOGCONFIGDIR" Order="2">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="regSetLOGINSTALLDIR" Order="3">PREVIOUSLOGINSTALLFOLDER</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="LogConfigDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="LogConfigDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg"></Publish>
<Publish Dialog="LogConfigDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg"></Publish>
On 'InstallDirDlg' 接下来我想做一些事情。首先是传递输入到“LOGCONFIG_DIR”属性中的“路径”...
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="SetLOGCONFIGDIR" Order="2">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<CustomAction Id="SetLOGCONFIGDIR" Property="LOGCONFIG_DIR" Value="[TESTSAVVY_SERVICES]" />
<!--Required for InstallDirDlg-->
<Property Id="WIXUI_INSTALLDIR" Value="TESTSAVVY_SERVICES" />
<!--Required for LogConfigDlg-->
<Property Id="LOGCONFIG_DIRECTORY" Value="LOGCONFIG_DIR" />
接下来是检查 LOGCONFIG_DIR 的注册表值,这个逻辑完美运行....
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="regSetLOGINSTALLDIR" Order="3">PREVIOUSLOGINSTALLFOLDER</Publish>
<CustomAction Id="regSetLOGINSTALLDIR" Property="LOGCONFIG_DIR" Value="[PREVIOUSLOGINSTALLFOLDER]" />
<Property Id="PREVIOUSLOGINSTALLFOLDER">
<RegistrySearch Id='LOGCONFIG_DIRRegSrch' Type='raw' Root='HKLM' Key='Software\[Manufacturer]\[ProductName]' Name='LOGCONFIG_DIR' />
</Property>
最后导航到下一个对话窗口。所以问题在于'Publish - Event="DoAction" Value="SetLOGCONFIGDIR"'。该目录不会反映用户在 InstallDirDlg 中放置的内容,除非用户在“LogConfigDlg”中按下“返回”按钮,然后在“InstallDirDlg”上再次按下“下一步”。
为什么用户第一次从“InstallDirDlg”按“下一步”时没有触发此操作,如上所述,用户必须返回该页面并再次按“下一步”?任何想法将不胜感激。
奇怪的是,设置几乎相同的其他操作在存在注册表项时工作正常。
更新
下面我在导航到下一个对话框窗口“LogConfigDlg”时包含日志部分。
记录何时存在注册表项('regSetLOGINSTALLDIR'),这有效...
Info 2898.For WixUI_Font_Title textstyle, the system created a 'Tahoma' font, in 0 character set, of 14 pixels height.
Action 13:56:36: InstallDirDlg. Dialog created
MSI (c) (18:20) [13:56:38:182]: Doing action: WixUIValidatePath
MSI (c) (18:20) [13:56:38:183]: Note: 1: 2205 2: 3: ActionText
Action 13:56:38: WixUIValidatePath.
Action start 13:56:38: WixUIValidatePath.
MSI (c) (18:20) [13:56:38:202]: Creating MSIHANDLE (3) of type 790542 for thread 27680
MSI (c) (18:34) [13:56:38:234]: Invoking remote custom action. DLL: C:\Users\WESLEY~1.MUR\AppData\Local\Temp\MSI23C8.tmp, Entrypoint: ValidatePath
MSI (c) (18!E4) [13:56:38:242]: Creating MSIHANDLE (4) of type 790541 for thread 13796
MSI (c) (18!E4) [13:56:38:243]: PROPERTY CHANGE: Adding WIXUI_INSTALLDIR_VALID property. Its value is '1'.
MSI (c) (18!E4) [13:56:38:243]: Closing MSIHANDLE (4) of type 790541 for thread 13796
MSI (c) (18:34) [13:56:38:244]: Closing MSIHANDLE (3) of type 790542 for thread 27680
Action ended 13:56:38: WixUIValidatePath. Return value 1.
MSI (c) (18:20) [13:56:38:246]: Doing action: regSetLOGINSTALLDIR
MSI (c) (18:20) [13:56:38:246]: Note: 1: 2205 2: 3: ActionText
Action 13:56:38: regSetLOGINSTALLDIR.
Action start 13:56:38: regSetLOGINSTALLDIR.
MSI (c) (18:20) [13:56:38:247]: PROPERTY CHANGE: Modifying LOGCONFIG_DIR property. Its current value is 'C:\TestSavvyService\'. Its new value: 'C:\TestSavvyService\hiwes'.
Action ended 13:56:38: regSetLOGINSTALLDIR. Return value 1.
Action 13:56:38: LogConfigDlg. Dialog created
MSI (c) (18:20) [13:56:40:356]: PROPERTY CHANGE: Modifying LOGCONFIG_DIR property. Its current value is 'C:\TestSavvyService\hiwes'. Its new value: 'C:\TestSavvyService\hiwes\'.
当注册表项不存在时记录。 'SetLOGCONFIGDIR' 应该在这两种情况下运行;但是,正如我们所见,它不是...
Info 2898.For WixUI_Font_Title textstyle, the system created a 'Tahoma' font, in 0 character set, of 14 pixels height.
Action 13:58:51: InstallDirDlg. Dialog created
MSI (c) (2C:4C) [13:58:54:966]: PROPERTY CHANGE: Modifying TESTSAVVY_SERVICES property. Its current value is 'C:\TestSavvyService\'. Its new value: 'C:\TestSavvyService\temp\'.
MSI (c) (2C:4C) [13:58:55:092]: Note: 1: 2727 2:
MSI (c) (2C:4C) [13:58:55:092]: Doing action: WixUIValidatePath
MSI (c) (2C:4C) [13:58:55:092]: Note: 1: 2205 2: 3: ActionText
Action 13:58:55: WixUIValidatePath.
Action start 13:58:55: WixUIValidatePath.
MSI (c) (2C:4C) [13:58:55:098]: Creating MSIHANDLE (3) of type 790542 for thread 27468
MSI (c) (2C:4C) [13:58:55:118]: Invoking remote custom action. DLL: C:\Users\WESLEY~1.MUR\AppData\Local\Temp\MSI3A92.tmp, Entrypoint: ValidatePath
MSI (c) (2C!04) [13:58:55:126]: Creating MSIHANDLE (4) of type 790541 for thread 16900
MSI (c) (2C!04) [13:58:55:127]: PROPERTY CHANGE: Adding WIXUI_INSTALLDIR_VALID property. Its value is '1'.
MSI (c) (2C!04) [13:58:55:127]: Closing MSIHANDLE (4) of type 790541 for thread 16900
MSI (c) (2C:4C) [13:58:55:128]: Closing MSIHANDLE (3) of type 790542 for thread 27468
Action ended 13:58:55: WixUIValidatePath. Return value 1.
Action 13:58:55: LogConfigDlg. Dialog created
Action 13:58:58: CancelDlg. Dialog created
【问题讨论】:
【参考方案1】:我已经解决了这个问题。以下是日志文件中现在正确的输出。
Info 2898.For WixUI_Font_Title textstyle, the system created a 'Tahoma' font, in 0 character set, of 14 pixels height.
Action 14:11:02: InstallDirDlg. Dialog created
MSI (c) (F4:F4) [14:11:08:732]: PROPERTY CHANGE: Modifying TESTSAVVY_SERVICES property. Its current value is 'C:\TestSavvyService\'. Its new value: 'C:\TestSavvyService\sad\'.
MSI (c) (F4:F4) [14:11:08:863]: Note: 1: 2727 2:
MSI (c) (F4:F4) [14:11:08:863]: Doing action: WixUIValidatePath
MSI (c) (F4:F4) [14:11:08:863]: Note: 1: 2205 2: 3: ActionText
Action 14:11:08: WixUIValidatePath.
Action start 14:11:08: WixUIValidatePath.
MSI (c) (F4:F4) [14:11:08:871]: Creating MSIHANDLE (3) of type 790542 for thread 12020
MSI (c) (F4:F8) [14:11:08:887]: Invoking remote custom action. DLL: C:\Users\WESLEY~1.MUR\AppData\Local\Temp\MSI6D07.tmp, Entrypoint: ValidatePath
MSI (c) (F4!68) [14:11:08:895]: Creating MSIHANDLE (4) of type 790541 for thread 30056
MSI (c) (F4!68) [14:11:08:896]: PROPERTY CHANGE: Adding WIXUI_INSTALLDIR_VALID property. Its value is '1'.
MSI (c) (F4!68) [14:11:08:896]: Closing MSIHANDLE (4) of type 790541 for thread 30056
MSI (c) (F4:F8) [14:11:08:896]: Closing MSIHANDLE (3) of type 790542 for thread 12020
Action ended 14:11:08: WixUIValidatePath. Return value 1.
MSI (c) (F4:F4) [14:11:08:899]: Doing action: SetLOGCONFIGDIR
MSI (c) (F4:F4) [14:11:08:899]: Note: 1: 2205 2: 3: ActionText
Action 14:11:08: SetLOGCONFIGDIR.
Action start 14:11:08: SetLOGCONFIGDIR.
MSI (c) (F4:F4) [14:11:08:899]: PROPERTY CHANGE: Modifying LOGCONFIG_DIR property. Its current value is 'C:\TestSavvyService\'. Its new value: 'C:\TestSavvyService\sad\'.
Action ended 14:11:08: SetLOGCONFIGDIR. Return value 1.
MSI (c) (F4:F4) [14:11:08:899]: Doing action: regSetLOGINSTALLDIR
MSI (c) (F4:F4) [14:11:08:899]: Note: 1: 2205 2: 3: ActionText
Action 14:11:08: regSetLOGINSTALLDIR.
Action start 14:11:08: regSetLOGINSTALLDIR.
MSI (c) (F4:F4) [14:11:08:899]: PROPERTY CHANGE: Modifying LOGCONFIG_DIR property. Its current value is 'C:\TestSavvyService\sad\'. Its new value: 'C:\TestSavvy\hiwes'.
Action ended 14:11:08: regSetLOGINSTALLDIR. Return value 1.
Action 14:11:08: LogConfigDlg. Dialog created
正如您所见,当注册表存在时,这两个操作都会被触发。并且注册表项的覆盖正确发生。
问题是由“订单”属性造成的。我很确定我的问题是由我使用 WiX 托管对话窗口 (InstallDirDlg) 引起的。该修复程序最终将“SetLOGCONFIGDIR”事件的“Order”属性设置为“3”,下面是“next”完整链的示例...
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="SetLOGCONFIGDIR" Order="3">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="DoAction" Value="regSetLOGINSTALLDIR" Order="3">PREVIOUSLOGINSTALLFOLDER</Publish>
<Publish Dialog="InstallDirDlg" Control="Next" Event="NewDialog" Value="LogConfigDlg" Order="4">WIXUI_DONTVALIDATEPATH OR WIXUI_INSTALLDIR_VALID="1"</Publish>
【讨论】:
以上是关于WiX - 从上一个对话框设置属性的主要内容,如果未能解决你的问题,请参考以下文章
WiX-Bootstrapper - 为 UAC 对话框设置产品名称和公司名称