2012-04-25 67 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時),您將收到「錯誤處理」錯誤。