.msi 文件能否自行安装(可能通过自定义操作)? [英] Can a .msi file install itself (presumably via a Custom Action)?

查看:20
本文介绍了.msi 文件能否自行安装(可能通过自定义操作)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个 MSI,它在安装过程中会将自身连同其包含的文件/组件一起部署到 TargetDir.

I wand to construct an MSI which, in its installation process, will deploy itself along with its contained Files/Components, to the TargetDir.

所以 MyApp.msi 在其文件表中包含 MyApp.exe 和 MyAppBootstrapperEmpty.exe(没有资源).

So MyApp.msi contains MyApp.exe and MyAppBootstrapperEmpty.exe (with no resources) in its File Table.

用户启动 MyAppBootstrapperPackaged.exe(包含作为资源的 MyApp.msi,从某处的 Internet 或电子邮件或其他方式获得).MyAppBootStrapperPackaged.exe 将 MyApp.msi 提取到临时文件夹并通过 msiexec.exe 执行.

The user launches a MyAppBootstrapperPackaged.exe (containing MyApp.msi as a resource, obtained from the internet somewhere, or email or otherwise). MyAppBootStrapperPackaged.exe extracts MyApp.msi to a temp folder and executes it via msiexec.exe.

msiexec.exe 进程完成后,我想要 MyApp.msi、MyBootstrapperEmpty.exe(以及 %ProgramFiles%MyApp 文件夹中的 MyApp.exe,以便 MyApp.exe 在运行时可以确保访问 MyApp.msi(用于创建下面提到的打包内容).

After the msiexec.exe process completes, I want MyApp.msi, MyBootstrapperEmpty.exe (AND MyApp.exe in %ProgramFiles%MyApp folder so MyApp.exe can be assured access to MyApp.msi when it runs (for creating the below-mentioned packaged content).

MyAppBootstrapper*.exe 可以尝试将 MyApp.msi 复制到 %ProgramFiles%MyApp 文件夹,但需要提升才能这样做,并且不允许通过 Windows Installer 卸载过程(从添加/删除程序或其他方式)将其删除),应该保留.

MyAppBootstrapper*.exe could try and copy MyApp.msi to %ProgramFiles%MyApp folder, but would need elevation to do so, and would not allow for its removal via Windows Installer uninstall process (from Add/Remove Programs or otherwise), which should be preserved.

显然(我认为这很明显 - 我错了吗?)我不能将 MSI 作为文件包含在我的媒体/CAB(鸡和蛋场景)中,所以我认为必须通过自定义操作来完成在安装过程之前,将原始 MSI 添加到 MSI DB 的媒体/CAB 和文件表中的相应条目.可以这样做吗?如果可以,怎么做?

Obviously (I think it's obvious - am I wrong?) I can't include the MSI as a file in my Media/CAB (chicken and egg scenario), so I believe it would have to be done via a Custom Action before the install process, adding the original MSI to the MSI DB's Media/CAB and the appropriate entry in the File table on the fly. Can this be done and if so how?

考虑一个内容分发模型,其中内容文件只与应用程序一起分发.内容由最终用户在运行时通过应用程序生成,并打包成一个可分发的 EXE,其中包括应用程序和内容.

Think of a content distribution model where content files are only ever to be distributed together with the App. Content is produced by the end user via the App at run time, and packaged into a distributable EXE which includes both the App and the content.

MyApp 的安装程序必须保持为 MSI,但可以由 Bootstrapper EXE 执行.安装的 MyApp.exe 必须同时访问 MyApp.msi 和 EXE 将由应用程序在运行时从基础(空)MyAppBootstrapper.exe(也由 MSI 安装)和由 MSI 创建的内容组装"最终用户.EXE 的资源 MSI 必须与安装运行时打包的 App 的资源 MSI 相同.

MyApp's installer must remain an MSI, but may be executed by a Bootstrapper EXE. The installed MyApp.exe must have access to both MyApp.msi and EXE is to be "assembled" at runtime by the App from a base (empty) MyAppBootstrapper.exe, which is also installed by the MSI, and the content created by the end-user. The EXE's resource MSI must be the same as that used to install the App which is doing the runtime packaging.

WIX 不能与 MyApp 一起安装.

WIX is not to be installed with MyApp.

在运行/打包时不能有网络依赖(即不能通过 Web 服务打包 - 必须在本地完成).

There can be no network dependencies at run-/packaging- time (i.e. can't do the packaging via a Webservice - must be done locally).

我熟悉(并使用)自定义操作(托管和非托管,通过 DTF 或其他方式).

I am familiar with (and using) Custom Actions (managed and unmanaged, via DTF and otherwise).

推荐答案

像这样向你的 wxs 添加一个未压缩的媒体:

Add an uncompressed medium to your wxs like this:

<Media Id='2'/>

然后用这样的 File 元素创建一个组件:

And then create a component with a File element like this:

<File Source='/path/to/myinstaller.msi' Compressed='no' DiskId='2' />

这将使安装程序在安装介质上查找名为myinstaller.msi"的文件,该文件与正在安装的 msi 位于同一文件夹中.上面的源路径应该指向一个虚拟文件,它只是为了安抚wix.

This will make the installer look for a file called "myinstaller.msi" on the installation medium, in the same folder as the msi that is being installed. The source path above should point to a dummy file, it is only there to appease wix.

编辑:以下示例 test.wxs 展示了它的工作原理.它会生成一个 test.msi 文件,该文件会自行安装到 c:program files est.请注意,您需要将虚拟 test.msi 文件与 text.wxs 放在同一文件夹中以安抚wix.

Edit: The following sample test.wxs demonstrates that it works. It produces a test.msi file which installs itself to c:program files est. Note that you need to put a dummy test.msi file in the same folder as text.wxs to appease wix.

<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
   <Product
         Name='ProductName'
         Id='*'
         Language='1033'
         Version='0.0.1'
         Manufacturer='ManufacturerName' >
      <Package
            Keywords='Installer'
            Description='Installer which installs itself'
            Manufacturer='ManufactererName'
            InstallerVersion='100'
            Languages='1033'
            Compressed='yes'
            SummaryCodepage='1252'/>

      <Media Id='1' Cabinet='test.cab' EmbedCab='yes'/> 
      <Media Id='2' /> 

      <Directory Id='TARGETDIR' Name="SourceDir">
         <Directory Id='ProgramFilesFolder'>
            <Directory Id='TestFolder' Name='Test' >
               <Component Id="InstallMyself">
                  <File Source="./test.msi" Compressed="no" DiskId="2" />
               </Component>
            </Directory>
         </Directory>
      </Directory>

      <Feature
            Id='Complete'
            Display='expand'
            Level='1'
            Title='Copy msi file to program files folder'
            Description='Test'>

         <ComponentRef Id="InstallMyself" />
      </Feature>

   </Product>
</Wix>

这篇关于.msi 文件能否自行安装(可能通过自定义操作)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆