mar*_*c_s 5 windows-installer wix install-sequence
我正在安装一个大型应用程序,其中一部分是一个名为"DbUpdateManager"的自定义编写工具,可以针对我们的目标数据库批量执行SQL脚本.
现在,WiX 2.x安装工作 - 但它有一个缺陷:在安装过程中,我还安装了几个Windows服务,可以选择立即启动.但是,如果DbUpdateManager尚未运行,那么这些将失败.
所以我想要完成的是:
我目前的WiX源代码如下:
<Directory Id='INSTALLDIR' Name='DbUpdMgr' LongName='DbUpdateManager' >
<!-- DbUpdateManager component with the necessary files -->
<Component Id='DbUpdateManagerComponent' Guid='...' DiskId='1'>
<File Id='DbUpdateManagerFile' LongName='DbUpdateManager.Wizard.exe'
Name='DbUmWz.exe' src='DbUpdateManager.Wizard.exe' KeyPath='no' />
</Component>
<!-- Component to install one of my Windows services -->
<Component Id='InstallServiceComponent' Guid='...' DiskId='1'>
<File Id='InstallServiceFile' LongName='MyService.exe'
Name='MyServic.exe' src='MyService.exe' KeyPath='yes'/>
<ServiceInstall Id='InstallMyService' Name='MyService'
Description='My Service' ErrorControl='normal'
Start='auto' Type='ownProcess' Vital='yes' />
<ServiceControl Id='UninstallMyService' Name='MyService'
Remove='uninstall' Wait='yes' />
</Component>
<!-- Feature for the DbUpdateManager referencing the above component -->
<Feature Id='DbUpdateManager' ConfigurableDirectory='INSTALLDIR'
AllowAdvertise='no' Description='DbUpdateManager' Level='1'
Title='Database Update Manager'>
<ComponentRef Id='DbUpdateManagerComponent'/>
</Feature>
<!-- Custom action for running DbUpdateManager -->
<CustomAction Id='RunDbUpdateManagerAction' FileKey='DbUpdateManagerFile'
ExeCommand='' Return='asyncWait' />
<!-- Calling the custom action in the install sequence -->
<InstallExecuteSequence>
<RemoveExistingProducts After='InstallInitialize' />
<Custom Action='RunDbUpdateManagerAction'
After='InstallFinalize'>&DbUpdateManager=3</Custom>
Run Code Online (Sandbox Code Playgroud)
我继承了这个WIX,它可以工作 - 但正如我所说的 - DbUpdateManager在进程中被调用得太晚(只有"After = InstallFinalize"),因此服务首先无法正常启动(第二次运行正常)在DbUpdateManager运行后手动重启它们时.
我稍微探讨了MSI文档并发现了一个名为"StartServices"的好步骤,所以我的预感是将我的调用自定义操作更改为:
<InstallExecuteSequence>
<Custom Action='RunDbUpdateManagerAction'
Before='StartServices'>&DbUpdateManager=3</Custom>
Run Code Online (Sandbox Code Playgroud)
不幸的是,在这种情况下,什么也没发生 - DbUpdateManager永远不会被调用....
有什么想法吗?调试MSI/WiX的东西真的很棘手,而且我似乎再也看不到森林了.
谢谢!渣
编辑:"RunDbUpdateManagerAction"被放置在在我的微星InstallExecuteSequence表中的正确位置-右后InstallServices而就在StartServices -然而它不工作.... DbUpdateManager(一个WinForms实用程序)并没有在显示出来安装:-(
编辑2:现在我的行动似乎在正确的时间执行 - 不幸的是,我只是没有看到我的向导:-(我所看到的是一个错误代码"返回值1631",这意味着像"微星服务"无法启动" - wtf ???
MSI(s)(2C:D8)[20:53:36:383]:执行操作:RunDbUpdateManagerAction操作20:53:36:RunDbUpdateManagerAction.行动开始于20:53:36:RunDbUpdateManagerAction.MSI(s)(2C:D8)[20:53:36:383]:执行操作:StartServices Action 20:53:36:StartServices.服务正在启动行动开始于20:53:36:StartServices.操作在20:53:36结束:RunDbUpdateManagerAction.返回值1631.
mar*_*c_s 10
好吧,我终于得到了它的工作 - 在回复的每个人的帮助下,并通过在网上咨询一些WiX教程和帮助页面.MSI安装程序的东西不容易弄清楚并学习......
基本上,我将自定义操作的执行更改为"延迟"(如Rob所建议的),并将执行顺序中的点移动到"After = InstallFiles".我还将<Custom>标签中的条件更改为"NOT Installed",这似乎在我的方案中工作得很好.
与Rob的恐惧相反,Db Update Manager及其UI以这种方式非常好地呈现,并且在我们的任何服务(依赖于数据库)开始之前,更新我们的数据库的过程现在已经完成.
期待完整的RTX版本的WiX 3.0(及其未来)!
感谢大家 - 不幸的是,我只能接受一个答案 - 所有人都应该得到它.
渣
您的CustomAction似乎取决于正在安装的'DbUpdateManagerFile'.这意味着需要在 InstallFiles执行后安排CustomAction .请记住,InstallExecuteSequence有两个传递.首先,执行"立即"(或"预定"或"脚本生成")动作以构建事务日志(又名:"安装脚本").其次,执行事务日志中的"延迟"操作.
现在你的CustomAction是"立即"(默认),所以它试图在文件实际复制到机器之前运行.InstallFiles操作位于CustomAction之前的脚本中,但尚未执行.
因此,您需要将CustomAction标记为"延迟",以便在安装文件后运行它.
注意:您可能无法显示来自延迟CA的UI.我不确定你的这个工具是否应该显示UI.
PS:对不起,如果我没有解释得那么好,那是漫长的一天.