问题描述
我正在安装一个大型应用程序,其中一部分是一个名为DbUpdateManager"的自定义编写工具,用于针对我们的目标数据库批量执行 SQL 脚本.
I'm installing a large app, and part of it is a custom written tool called "DbUpdateManager" to mass execute SQL scripts against our target database.
现在,WiX 2.x 安装工作正常 - 但它有一个缺陷:在安装过程中,我还安装了几个 Windows 服务,可以选择立即启动.但是,如果 DbUpdateManager 尚未运行,这些将失败.
Right now, the WiX 2.x install works - but it has one flaw: during install, I also install a couple of Windows services, which can be optionally started right away. Those however will fail, if the DbUpdateManager hasn't been run yet.
所以我想要完成的是:
- 从我的 MSI 安装 DbUpdateManager 和我的服务
- 在任何服务启动之前运行 DbUpdateManager
- Install DbUpdateManager and my services from my MSI
- Run DbUpdateManager BEFORE any of the services start up
我当前的 WiX 源如下所示:
My current WiX source looks something like this:
<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 运行后手动重新启动它们时).
I inherited this WIX, and it works - but as I said - the DbUpdateManager gets called too late in the process (only "After=InstallFinalize") and thus the services will fail to start up properly at first (the run fine the second time around when you restart them manually after DbUpdateManager has run).
我稍微浏览了 MSI 文档,发现了一个名为StartServices"的好步骤,所以我的直觉是将我调用的自定义操作更改为:
I poked around the MSI documentation a bit and found a nice step called "StartServices", so my hunch was to just change my calling the custom action to this:
<InstallExecuteSequence>
<Custom Action='RunDbUpdateManagerAction'
Before='StartServices'>&DbUpdateManager=3</Custom>
不幸的是,在这种情况下,什么也没有发生 - DbUpdateManager 永远不会被调用......
Unfortunately, in this case, nothing at all happens - DbUpdateManager NEVER gets called....
有什么想法吗?调试 MSI/WiX 的东西真的很棘手,我似乎再也见不到树木了......
Any ideas why? Debugging the MSI/WiX stuff is really really tricky, and I can't seem to see the forest for the trees anymore....
谢谢!马克
RunDbUpdateManagerAction"被放置在我 MSI 的 InstallExecuteSequence 表中的正确位置 - 就在 InstallServices 之后,就在 StartServices 之前 - 但它不起作用...... DbUpdateManager(一个 Winforms 实用程序)确实 不在安装过程中出现:-(
The "RunDbUpdateManagerAction" is placed in the right position in the InstallExecuteSequence table in my MSI - right AFTER InstallServices and just BEFORE StartServices - and yet it doesn't work.... DbUpdateManager (a Winforms utility) does not show up during installation :-(
编辑 2:现在我的操作似乎在正确的时间执行了 - 不幸的是,我只是没有看到我的向导 :-( 我看到的是错误代码返回值 1631",这意味着类似MSI 服务无法启动" - wtf ???
EDIT 2: now my action appears to be executed and at the right time - unfortunately, I'm just not seeing my wizard :-( What I'm seeing is an error code "return value 1631" which means something like "MSI Service could not be started" - 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:StartServices.服务正在启动行动开始于 20:53:36:StartServices.操作在 20:53:36 完成:RunDbUpdateManagerAction.返回值 1631.
MSI (s) (2C:D8) [20:53:36:383]: Doing action: RunDbUpdateManagerActionAction 20:53:36: RunDbUpdateManagerAction.Action started at 20:53:36: RunDbUpdateManagerAction.MSI (s) (2C:D8) [20:53:36:383]: Doing action: StartServicesAction 20:53:36: StartServices. Services are being startedAction started at 20:53:36: StartServices.Action finished at 20:53:36: RunDbUpdateManagerAction. Return value 1631.
推荐答案
尝试获取安装的日志文件,并在其中查找序列顺序和执行自定义操作的条件值
Try getting a log file of the Installation, and look for the sequence order in there and the value of the condition to perform the Custom Action
在命令行中使用它:msiexec/i [msiname]/l*v [文件名]
Use this in the command line:msiexec /i [msiname] /l*v [filename]
阅读您的评论后,请查看此页面 here 您可以尝试在条件中添加 NOT INSTALLED
After reading your comment have a look at this page here you could try to add NOT INSTALLED in the condition
我发现了这个 page 搜索您的错误编号 1631
I found this page Search for your error Number 1631
这篇关于WiX - 试图找出安装顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!