WiX - 试图找出安装顺序

时间:2009-04-22 16:55:14

标签: wix windows-installer install-sequence

我正在安装一个大型应用程序,其中一部分是一个名为“DbUpdateManager”的自定义编写工具,可以针对我们的目标数据库大量执行SQL脚本。

目前,WiX 2.x安装有效 - 但它有一个缺陷:在安装过程中,我还安装了几个Windows服务,可以选择立即启动。但是,如果DbUpdateManager尚未运行,那么这些将失败。

所以我想要完成的是:

  1. 从我的MSI安装DbUpdateManager和我的服务
  2. 运行DbUpdateManager 之前启动任何服务
  3. 我目前的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'>&amp;DbUpdateManager=3</Custom>
    

    我继承了这个WIX,它可以工作 - 但正如我所说 - DbUpdateManager在进程中被调用太晚(只有“After = InstallFinalize”),因此服务首先无法正常启动(运行正常)第二次在DbUpdateManager运行后手动重启它们。)

    我稍微探讨了MSI文档并发现了一个名为“StartServices”的好步骤,所以我的预感是将我的调用自定义操作更改为:

       <InstallExecuteSequence>
              <Custom Action='RunDbUpdateManagerAction' 
                      Before='StartServices'>&amp;DbUpdateManager=3</Custom>
    

    不幸的是,在这种情况下,什么也没发生 - DbUpdateManager永远不会被调用....

    任何想法为什么?调试MSI / WiX的东西真的很棘手,而且我似乎再也看不到树林了....

    谢谢! 马克

    编辑:“RunDbUpdateManagerAction”被放置在我的MSI中的InstallExecuteSequence表中的正确位置 - 在安装服务之后和刚刚启动服务之后 - 但它不起作用.... DbUpdateManager(Winforms实用程序)执行< em> 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:StartServices。服务正在启动 行动开始于20:53:36:StartServices。 操作在20:53:36结束:RunDbUpdateManagerAction。返回值1631。

4 个答案:

答案 0 :(得分:10)

好吧,我终于得到了它的帮助 - 得到了所有回复的人的帮助,并在网上查阅了一些WiX教程和帮助页面。 MSI安装程序的东西不容易理解和学习......

基本上,我将自定义操作的执行更改为“延迟”(如Rob所建议的),并将执行顺序中的点移动到“After = InstallFiles”。我还改变了&lt; Custom&gt;中的条件。标记为“未安装”,这似乎在我的方案中正常工作。

与Rob的恐惧相反,Db Update Manager及其UI以这种方式出现得非常好,并且在我们的任何服务(依赖于数据库)开始之前,更新数据库的过程现已完成。

期待完整的RTX版本的WiX 3.0(及其未来)!

感谢所有人 - 不幸的是,我只能接受一个答案 - 所有人都应该得到它。

马克

答案 1 :(得分:6)

您的CustomAction似乎取决于正在安装的'DbUpdateManagerFile'。这意味着您的CustomAction需要在 InstallFiles执行后进行安排。请记住,InstallExecuteSequence有两个传递。首先,执行“立即”(或“预定”或“脚本生成”)动作以构建事务日志(又名:“安装脚本”)。其次,执行事务日志中的“延迟”操作。

现在你的CustomAction是“立即”(默认),所以它试图在文件实际复制到机器之前运行。 InstallFiles操作位于CustomAction之前的脚本中,但尚未执行。

因此,您需要在安装文件后将CustomAction标记为“延迟”以使其运行

注意:您可能无法显示来自延迟CA的UI。我不确定你的这个工具是否应该显示UI。

PS:对不起,如果我没有那么好解释,那是漫长的一天。

答案 2 :(得分:5)

尝试获取安装的日志文件,并在其中查找序列顺序以及执行自定义操作的条件值

在命令行中使用此命令: msiexec / i [msiname] / l * v [filename]

编辑:阅读完评论后,请查看此页here,您可以尝试在条件中添加NOT INSTALLED

EDIT2:我发现此page搜索您的错误号码1631

答案 3 :(得分:4)

您可以在Orca中打开.msi,然后查看InstallExecuteSequence表,了解实际发生的事情。这可能会让您了解实际发生的事情。