在Windows Installer 4.5 中,为MsiEmbeddedChainer表添加了一个新表。该表应该允许多包安装。WiX 通过创建EmbeddedChainer元素添加了对表格的支持。我已经阅读了 wiki,但是有没有关于如何使用该元素的示例?
我正在尝试在我的程序之前安装JRE 。
在Windows Installer 4.5 中,为MsiEmbeddedChainer表添加了一个新表。该表应该允许多包安装。WiX 通过创建EmbeddedChainer元素添加了对表格的支持。我已经阅读了 wiki,但是有没有关于如何使用该元素的示例?
我正在尝试在我的程序之前安装JRE 。
Embedded chainers only work after the installer that contained them is installed, and can only install raw .msi files (.msi files with their own bootstrap .exe files cannot be used), so I don't think you'll be able to install the JRE the way you want.
下面的 c# 代码中有一个错误:在“IntPtr ptr = new IntPtr(Convert.ToInt32(args[0], 16));”行中 “16”必须是“10”!
否则,当有超过 10 个事务时(例如,当从嵌入式链接器调用五个或更多子 msi 时),您将收到“错误处理”错误。
执行以下步骤:
WXS 文件中的更改:...
<Component DiskId="1" Guid="5CE59096-E197-4694-8DC2-E8EB4601C7C5" Id="CHAINERRUN.EXE">
<File Id="CHAINERRUN.EXE" Name="ChainerRun.exe" Source="..\ClinAppChainers\bin\ChainerRun.exe" />
<File Id="MICROSOFT.DEPLOYMENT.WINDOWSINSTALLER.DLL" Name="Microsoft.Deployment.WindowsInstaller.dll" Source="C:\Program Files\Windows Installer XML v3.6\SDK\Microsoft.Deployment.WindowsInstaller.dll" />
<File Id="MICROSOFT.CSHARP.DLL" Name="Microsoft.CSharp.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.CSharp.dll" />
<File Id="SYSTEM.DLL" Name="System.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll" />
<File Id="SYSTEM.CORE.DLL" Name="System.Core.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll" />
<File Id="SYSTEM.XML.DLL" Name="System.Xml.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.dll" />
<File Id="SYSTEM.XML.LINQ.DLL" Name="System.Xml.Linq.dll" Source="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Xml.Linq.dll" />
</Component>
...
<EmbeddedChainer Id="ChainerRun" FileSource="CHAINERRUN.EXE" />
FileSource 是对组件中定义的 File 元素 ID 的引用
创建一个 C# 项目,引用文件 Microsoft.Deployment.WindowsInstaller.dll,或创建一个新的 WIX“C# 自定义操作项目”,然后将输出更改为控制台应用程序 EXE 而不是 DLL。CS 文件的主体应包含 Main 函数
ChainerRun.CS
namespace ChainerRun
{
public class CustomActions
{
static void Main(string[] args)
{
System.Diagnostics.Debugger.Launch();
try
{
IntPtr ptr = new IntPtr(Convert.ToInt32(args[0], 16));
//ptr = System.Runtime.InteropServices.Marshal.StringToCoTaskMemAuto(args[0]);
Transaction transaction = Transaction.FromHandle(ptr, true);
transaction.Join(TransactionAttributes.JoinExistingEmbeddedUI);
// Installer.InstallProduct(@"c:\MyOtherApp.msi", argline);
transaction.Commit();
transaction.Close();
}
catch (Exception e)
{
throw e;
}
}
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
System.Diagnostics.Debugger.Launch();
session.Log("My CustomAction1() begins ...");
}
}
将 JRE 作为一个包嵌入到多包事务中的方法是一种矫枉过正的做法,它不必要地使维护复杂化。
有两种合理的解决方案,维护成本低。