且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Wix-如何在没有UI的情况下运行/安装应用程序

更新时间:2022-11-03 14:21:40

不要嵌入在MSI文件中设置可执行文件



好,这个问题不是100%明确的,但我会试一试。以这种方式(嵌入在MSI文件中)传递EXE文件并不理想。实际上,这是一个非常糟糕的主意-说实话。通常,不应仅将MSI文件用作包装程序来传递嵌入式setup.exe文件。 MSI的复杂性及其高级模拟,排序和条件处理,使得此错误非常容易发生,并且难以实施和测试。此外,如果您嵌入的二进制文件原来是包裹在setup.exe二进制文件中的MSI文件,则MSI将失败,因为它不允许两个并发安装序列-除非您从用户界面序列安装它们(否则将不会)

Don't embed setup executable in MSI files

OK, the question isn't 100% clear, but I will give it a go. Delivering EXE files this way - embedded in MSI file - is not ideal. In fact it is a very bad idea - truth be told. MSI files should generally not be used just as wrappers to deliver embedded setup.exe files. The sheer complexity of MSI with its advanced impersonation, sequencing and conditioning makes this very error prone and hard to implement and test. Additionally, if the binary you embed turns out to be an MSI file wrapped in a setup.exe binary, then MSI will fail because it doesn't allow two concurrent installation sequences - unless you install them from the user interface sequence (which won't work when running silently).

MSI文件在静默模式下(无GUI)可靠运行的能力无法与旧式设置相提并论。但是,通常您可以找到旧版(或较新的) setup.exe 或安装二进制文件的开关,这些开关将允许以静默模式安装该开关,但不能以MSI提升的安装权限进行安装。您必须以实际的管理员权限运行。另外,您通常必须通过对话框记录运行并使用记录的响应来运行安装顺序-这容易出错,因为意外的对话框可能会显示没有记录的响应的地方。然后你被困住了。 MSI可靠的静默运行是MSI的主要企业优势之一

The ability of MSI files to run reliably in silent mode (without GUI) can not be matched by legacy style setups. However, often you can find switches for a legacy (or modern) setup.exe or installation binary which will allow it to be installed in silent mode, but not with MSI elevated installation rights. You would have to run with real admin rights. And additionally you often have to "record" a run though the dialogs and use the recorded responses to run the installation sequence - this is error prone since an unexpected dialog could show up where there is no recorded "response". Then you are stuck. MSI's reliable silent running is one of the key corporate advantages of MSI.

您可以在我前一段时间写的这个答案中找到很多有关此的信息: 如何使用Powershell来运行安装程序? 强>。不要让问题标题使您感到困惑,问题仍然与您要问的问题非常相似-至少我是这样认为的。

You can find a lot of information on this in this answer that I wrote a while ago: How can I use powershell to run through an installer?. Don't let the question title confuse you, the issue is still quite similar to what you are asking - at least I think so. Please give it a quick skim at least.

答案还描述了 应用程序重新打包-转换旧式(或现代)设置的过程.exe安装程序转换为本地MSI格式。这是一项需要精通MSI的专业任务,但一旦正确完成就可以产生出色的结果,并且静默安装非常容易,因为您不必依赖于上述脆弱的静默响应文件。

The answer also describes "Application Repackaging" - the process of converting legacy (or modern) setup.exe installers to native MSI format. This is a specialist task requiring good understanding of MSI but yields excellent results once done right, and silent installation is a breeze since you don't rely on frail "silent response files" as described above.

尽管我不确定它们是否都允许您以静默方式安装,有可用的工具可让您从启动器EXE文件依次安装MSI文件和安装二进制文件。这里还有另一个讨论各种引导程序选项的答案: Wix和.NET Framework(先决条件) 。在本讨论中推荐的引导程序之一是 dotNetInstaller 。我从未使用过,所以无法告诉您它是否有用。它可能比WiX自己的称为 刻录 ,但是我不确定这是否符合功能。如果您进行测试,请报告您的发现。当然还有其他引导者,但这不是我的专业领域。诸如Installshield(至少在其高级版本中)之类的商业工具具有使用GUI构建此类引导程序的功能,我认为它们将其称为安装套件或类似的东西。本质上只是一堆安装程序和先决条件。我还没有尝试高级安装程序中的此引导程序功能

Though I am not sure if they all allow you to install in silent mode, there are tools available that allow you to install MSI files and installation binaries in sequence from a launcher EXE file. There is another answer discussing various bootstrapper options here: Wix and .NET Framework (prerequisites). One of the bootstrappers recommended in the this discussion is dotNetInstaller. I have never used it, so I can't tell you if it is any good. It may be more GUI-based than WiX's own bootstrapper feature called Burn, however I am not sure if it is a match feature-wise. If you do test, please report your findings. There are certainly other bootstrappers out there, but it is not my area of expertise. Commercial tools such as Installshield (in their Premium version at least), have features to build such a bootstrapper using a GUI and I think they refer to them as "Install Suites" - or something like that. Just a bundle of installers and prerequisites essentially. I haven't tried this bootstrapper feature in Advanced Installer.

关于刻录:


  • Burn基于XML标记和编译-通常使用Visual Studio。

  • 以下是如何使用Burn 安装.NET Framework。

  • Burn的官方文档

  • 如您所见,它比允许您使用GUI构建安装程序序列或链的工具要复杂得多。

  • 它是免费且可靠的。

  • 我将尝试为您提取Burn样本。

  • 好的,这应该是Burn可以做什么的一个好的示例: https://github.com/frederiksen/Classic-WiX-Burn-Theme 。我认为此示例中有一些重复的Visual Studio项目GUID,但这对您来说应该不是问题,除非您出于某种原因将两个项目都添加到了构建过程中(然后,重复的GUID可能会混淆您的构建工具-只是

  • 需要明确的是,Burn建立了能够同时包含MSI文件和EXE文件的setup.exe引导程序捆绑包,该捆绑包以给定的顺序运行,并且它是WiX工具包。 WiX本身从WiX XML源文件构建MSI文件。刻录setup.exe文件也是从WiX XML源文件构建的,但是架构明显不同。只适合那些从未看过这些工具的人。上面的示例将很好地显示WiX MSI项目和WiX Burn项目的区别。它还有一个构建二进制文件的项目,然后将该二进制文件包含在MSI和setup.exe中。

  • Burn is based on XML markup and compilation - generally using Visual Studio.
  • Here is a description of How to install the .NET Framework using Burn.
  • The official documentation for Burn.
  • As you see it is a bit more involved than the tools that allow you to use a GUI to build your sequence or "chain" of installers.
  • It is free and reliable.
  • I will try to dig up a Burn sample for you.
  • OK, this should be an OK sample of what Burn can do: https://github.com/frederiksen/Classic-WiX-Burn-Theme. There are some duplicated Visual Studio project GUIDs in this sample, I think, but that shouldn't be a problem for you unless you for some reason add both projects to your build process (then the duplicated GUIDs will likely confuse your build tools - just something that happened to me once).
  • Just to be clear, Burn builds setup.exe bootstrapper bundles capable of containing both MSI files and EXE files run in a given sequence and it is part of the WiX toolkit. WiX itself builds MSI files from WiX XML source files. Burn setup.exe files are also built from WiX XML source files, but the schema is obviously different. Just for those who have never seen these tools. The sample directly above will show the difference nicely with both a WiX MSI project and a WiX Burn project. It also has a project to build a binary that is then included in both the MSI and the setup.exe.