Bootstrapper:如何在单个 .msi 包中编译应用程序和先决条件?

发布于 2024-07-13 20:39:21 字数 1868 浏览 7 评论 0原文

我正在为该应用程序创建一个 .msi 包,该应用程序具有安装先决条件。 我使用 Visual Studio 2005 Bootstrapper 来完成此任务。 为此,我做了以下工作: 找到文件夹 C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\ 并为我的先决条件创建一个文件夹(使其结构与“dotnetfx”相同); 创建了“product.xml”和“package.xml”并将它们放置在适当的位置。 到目前为止,我保持 xml 文件非常简单来测试安装:

product.xml

<?xml version="1.0" encoding="utf-8"?>
<Product ProductCode="MyPrereq" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <PackageFiles CopyAllPackageFiles="false">
    <PackageFile Name="MyPrereq.exe" />
  </PackageFiles>
  <InstallChecks>
  </InstallChecks>
  <Commands Reboot="None">
    <Command PackageFile="MyPrereq.exe" EstimatedInstallSeconds="90">
      <InstallConditions>
      </InstallConditions>
      <ExitCodes>
    <ExitCode Value="0" Result="Success"/>
        <DefaultExitCode Result="Fail" String="GeneralFailure" FormatMessageFromSystem="true" />
      </ExitCodes>
    </Command>
  </Commands>
</Product>

package.xml

<?xml version="1.0" encoding="utf-8"?>
<Package Name="MyPrereq" Culture="Culture" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <Strings>
    <String Name="Culture">en</String>
    <String Name="DisplayName">MyPrereq</String>
    <String Name="GeneralFailure">A fatal error occurred. The installation failed.</String>
  </Strings>
</Package>

现在我可以从列表中添加先决条件并构建我的安装项目。

问题:

构建输出是“setup.exe”、“MyApp.msi”包,以及包含“MyPrereq.exe”的名为“MyPrereq”的子文件夹。

我希望构建创建一个“setup.exe”和一个“MyApp.msi”,其中包含“MyPrereq”,没有其他文件/目录。

我知道 .NET 框架是我的应用程序的另一个先决条件,并且它包含在同一个 .msi 中,因此应该可以以某种方式实现。

我怎样才能实现这个目标?

I am creating an .msi package for the application which has a prerequisite for installation.
I am using the Visual Studio 2005 Bootstrapper for this task.
To this end, I did the following:
Located the folder C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\BootStrapper\Packages\ and created a folder for my prerequisite (made it same structure as 'dotnetfx'); created the 'product.xml' and 'package.xml' and placed them appropriately. I kept the xml files very simple so far to test the installation:

product.xml

<?xml version="1.0" encoding="utf-8"?>
<Product ProductCode="MyPrereq" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <PackageFiles CopyAllPackageFiles="false">
    <PackageFile Name="MyPrereq.exe" />
  </PackageFiles>
  <InstallChecks>
  </InstallChecks>
  <Commands Reboot="None">
    <Command PackageFile="MyPrereq.exe" EstimatedInstallSeconds="90">
      <InstallConditions>
      </InstallConditions>
      <ExitCodes>
    <ExitCode Value="0" Result="Success"/>
        <DefaultExitCode Result="Fail" String="GeneralFailure" FormatMessageFromSystem="true" />
      </ExitCodes>
    </Command>
  </Commands>
</Product>

package.xml

<?xml version="1.0" encoding="utf-8"?>
<Package Name="MyPrereq" Culture="Culture" xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper">
  <Strings>
    <String Name="Culture">en</String>
    <String Name="DisplayName">MyPrereq</String>
    <String Name="GeneralFailure">A fatal error occurred. The installation failed.</String>
  </Strings>
</Package>

Now I can add the prerequisite from the list and build my setup project.

The problem:

The build output is the 'setup.exe', the 'MyApp.msi' package, plus the subfolder called 'MyPrereq' which contains 'MyPrereq.exe'.

I would like the build to create a 'setup.exe' and a single 'MyApp.msi', which would contain the 'MyPrereq' inside, with no additional files/directories.

I know that the .NET framework is another prereq for my app, and it is included in the same .msi, so that should be possible somehow.

How can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

堇色安年 2024-07-20 20:39:21

您可以使用 IExpress(Windows 附带)等工具创建自解压安装程序,其中包含单个可执行文件中的所有文件(请参阅此所以发帖)。

您不能让 MSI 文件安装其自己的先决条件。 首先,因为 Windows Installer 本身是先决条件(并且必须由非 MSI exe 安装),其次因为 Windows Installer 安装是事务性的,并且不支持 MSI 文件的链式执行。 这基本上意味着一个 MSI 安装无法启动另一个 MSI 安装。 因此,任何先决条件都必须由单独的引导程序安装(顺便说一句,安装不再是事务性的 - 如果 MSI 安装失败,先决条件将不会被卸载)。

不过,对于引导程序机制似乎存在一个基本的误解。 引导程序当前只能由 Visual Studio 或 MSBuild 生成。 据我所知,WiX 是不可能的。 在 MSBuild 中查找GenerateBootstrapper 任务(请参阅此 SO 帖子)。

You can create a self-extracting installer with tools such as IExpress (coming with Windows) containing all files in a single executable (see this SO posting).

You cannot have an MSI file installing its own pre-requisites. First, because Windows Installer itself is a pre-requisite (and must be installed by a non MSI exe) and second because Windows Installer installations are transactional and don't support the chained execution of MSI files. This basically means that one MSI installation cannot start another MSI installation. As a consequence, any pre-requisites must be installed by a separate bootstrapper (by the way, the installation is no longer transactional - the pre-requisites won't get uninstalled if your MSI installation fails).

There seems to be a basic mis-understanding about the bootstrapper mechanism though. The bootstrapper can currently only be generated by Visual Studio or MSBuild. Afaik it is not possible with WiX. Look for the GenerateBootstrapper task in MSBuild (see this SO posting).

风吹雪碎 2024-07-20 20:39:21

我用 IExpress 成功做到了这一点。

然而,必须使用一个小技巧,如下所述
为 VS Shell 应用程序创建引导程序

不幸的是,MSBuild 任务
不提供选项
配置资源使用
中找到的必备安装程序
目标目录,所以你必须手动
更新相应的资源文件
删除硬编码路径
寻找先决条件
同名子目录。

  • 在Visual中打开Setup.exe程序
    Studio 的资源编辑器
  • 双击
    41 中名为 SETUPCFG 的资源
    文件夹
  • 搜索“Vs Shell\”
    字符串并删除出现的两次
    出现的
  • 保存资源文件
    并且Setup.exe可执行文件将是
    自动更新
  • 运行 iexpress
  • 按照以下步骤创建一个新包
    IExpress 向导的步骤并确保
    包括以下文件:
  • MyVSShellApplication.msi 文件
  • setup.exe引导程序文件
  • vs_shell_isolated.enu.exe 文件

  • 问题是引导程序将先决条件放入子文件夹中,而 IExpress 无法识别子文件夹。 编辑“setup.exe”时也必须小心,第一次尝试时没有正确。

    I managed to do that with IExpress.

    Had to use a small trick, however, which is described here
    Creating a bootstrapper for a VS Shell application

    Unfortunately, the MSBuild task
    doesn't provide the option to have the
    configuration resource use
    prerequisite installers found in the
    target directory, so you must manually
    update the appropriate resource file
    to remove the hard-coded path that
    looks for prerequisites in a
    sub-directory of the same name.

  • Open the Setup.exe program in Visual
    Studio's resource editor

  • Double-click
    the resource named, SETUPCFG in the 41
    folder

  • Search for the "Vs Shell\"
    string and delete the two occurrences
    that appear

  • Save the resource file
    and the Setup.exe executable will be
    updated automatically

  • Run iexpress
  • Create a new package by following the
    IExpress wizard's steps and make sure
    to include the following files:

  • The
    MyVSShellApplication.msi file

  • The
    Setup.exe bootstrapper file

  • The
    vs_shell_isolated.enu.exe file

  • The problem was that bootstrapper puts the prerequisites into a subfolder, and IExpress does not recognise subfolders. Have to be careful while editing 'setup.exe' too, didn't get it correct on the first try.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文