我正在安装一个大型应用程序,其中一部分是一个名为“DbUpdateManager”的自定义编写工具,用于针对我们的目标数据库批量执行 SQL 脚本。
现在,WiX 2.x 安装可以工作,但它有一个缺陷:在安装过程中,我还安装了一些 Windows 服务,可以选择立即启动这些服务。但是,如果 DbUpdateManager 尚未运行,这些操作将会失败。
所以我想要完成的是:
- 从我的 MSI 安装 DbUpdateManager 和我的服务
- 运行 DbUpdateManagerBEFORE任何服务启动
我当前的 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>
我继承了这个 WIX,它可以工作 - 但正如我所说 - DbUpdateManager 在该过程中被调用得太晚(仅“After=InstallFinalize”),因此服务首先将无法正常启动(第二次运行良好)当您在 DbUpdateManager 运行后手动重新启动它们时)。
我浏览了一下 MSI 文档,发现了一个名为“StartServices”的好步骤,所以我的直觉是将我的自定义操作调用更改为:
<InstallExecuteSequence>
<Custom Action='RunDbUpdateManagerAction'
Before='StartServices'>&DbUpdateManager=3</Custom>
不幸的是,在这种情况下,什么也没有发生 - DbUpdateManager 永远不会被调用......
有什么想法吗?调试 MSI/WiX 的东西真的非常棘手,我似乎再也见不到树木了......
谢谢!
马克
编辑:“RunDbUpdateManagerAction”被放置在我的MSI中InstallExecuteSequence表中的正确位置 - 在InstallServices之后和StartServices之前 - 但它不起作用...... DbUpdateManager(一个Winforms实用程序)确实not安装过程中出现:-(
编辑 2:现在我的操作似乎已在正确的时间执行 - 不幸的是,我只是没有看到我的向导:-( 我看到的是错误代码“返回值 1631”,这意味着类似“MSI 服务”无法启动”-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
操作 20:53:36:启动服务。服务正在启动中
操作于 20:53:36 开始:StartServices。
操作于 20:53:36 完成:RunDbUpdateManagerAction。返回值1631。