2012-04-25 52 views
0

我正在尝试使用Windows Installer嵌入式链安装多个.msi(s)。我研究了一个网站的一些信息,我试了一下。但它不起作用(WiX + C#)。使用嵌入式EmbeddedChainer安装多个MSI

  1. 当我检查了调试,它工作顺利,直到transaction.Commit()transaction.close()。但是SampleApp.msi没有安装。
  2. 即使SampleApp.msi无法正常工作,'Multiple MISs Installer'安装成功,我无法卸载'Multiple MISs Installer'。错误日志中的条目是“安装过程中的致命错误”。

我该如何解决?

多的MSI安装\ Product.wxs

<Directory Id="TARGETDIR" Name="SourceDir"> 
    <Directory Id="ProgramFilesFolder"> 
     <Directory Id="INSTALLLOCATION" Name="Multiple Installer"> 
      <Component Id="InstallMSIComponent" Guid="{7091DE57-7BE3-4b0d-95D5-07EEF6463B62}"> 
       <File Id="FILE_MprjChainer.exe" Name="MprjChainer.exe" 
         Source="C:\A_VS2008\WiX\MprjChainer\MprjChainer\bin\Debug\MprjChainer.exe" 
         DiskId="1" KeyPath="yes"/> 
       <File Id="Microsoft.Deployment.WindowsInstaller.dll" 
         Name="Microsoft.Deployment.WindowsInstaller.dll" 
         Source="C:\Program Files\Windows Installer XML v3.5\SDK\Microsoft.Deployment.WindowsInstaller.dll" /> 
       <File Id="System.dll" 
         Name="System.dll" 
         Source="C:\windows\Microsoft.NET\Framework\v2.0.50727\System.dll" /> 
       <File Id="System.Core.dll" Name="System.Core.dll" 
         Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /> 
       <File Id="System.Windows.Forms.dll" Name="System.Windows.Forms.dll" 
         Source="C:\windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll" /> 
       <File Id="System.Xml.dll" 
         Name="System.Xml.dll" 
         Source="C:\windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll" /> 
       <File Id="System.Xml.Linq.dll" 
         Name="System.Xml.Linq.dll" 
         Source="c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /> 
       <RemoveFolder Id="INSTALLLOCATION" On="uninstall"/> 
      </Component> 

      <Component Id="CMPG_SimpleApp" Guid="{CB568AA4-9790-4efd-91BB-82682F063321}"> 
       <File Id="SimpleApp.msi" 
         Name="SimpleApp.msi" 
         Source="C:\A_VS2008\WiX\MSIs\SimpleApp.msi" 
         DiskId="1" KeyPath="yes"/> 
      </Component> 
     </Directory> 
    </Directory> 
</Directory> 

<EmbeddedChainer Id="Chainer" FileSource="FILE_MprjChainer.exe"/> 

<Feature Id="ProductFeature" Title="MPrjInstaller" Level="1"> 
    <ComponentRef Id="InstallMSIComponent"/> 
    <ComponentRef Id="CMPG_SimpleApp"/> 
    <ComponentGroupRef Id="Product.Generated" /> 
</Feature> 

Chainer \ CustonAction.cs

namespace MprjChainer 
{ 
    public class CustomActions 
    { 
     static void Main(string[] args) 
     { 
      System.Diagnostics.Debugger.Launch(); 

      try 
      { 
       IntPtr ptr = new IntPtr(Convert.ToInt32(args[0], 16)); 
       Transaction transaction = Transaction.FromHandle(ptr, true); 

       transaction.Join(TransactionAttributes.JoinExistingEmbeddedUI); 

       transaction.Commit(); 
       transaction.Close(); 
      } 
      catch (Exception e) 
      { 
       System.Windows.Forms.MessageBox.Show("e.Message; " + e.Message); 
       throw e; 
      } 
     } 

     [CustomAction] 
     public static ActionResult CustomAction1(Session session) 
     { 
      System.Diagnostics.Debugger.Launch(); 
      session.Log("Begin CustomAction1"); 

      return ActionResult.Success; 
     } 
    } 
} 

回答

0

尝试调用InstallProduct():

transaction.Join(TransactionAttributes.JoinExistingEmbeddedUI); 

// start another installation in the same transaction 
Installer.InstallProduct(@"path_To_Your_MSI", arguments); 
// it's good to include /l*v install.log in the arguments so that you'll get a verbose log of the installation 

transaction.Commit(); 

的一个例子嵌入式Chainer可以看出:WiX EmbeddedChainer Examples?

你也可以看看烧伤(从维克斯引导程序/ chainer)用于链接多个MSI软件包:http://robmensching.com/blog/posts/2009/7/14/Lets-talk-about-Burn

0

有一个在C#代码中的错误: 在行“的IntPtr ptr = new IntPtr(Convert.ToInt32(args [0],16));“ “16”必须是“10”!

否则,当超过10个事务时(例如,从嵌入式链接器调用五个或更多个子msi时),您将收到“错误处理”错误。