且构网

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

.msi 文件是否可以自行安装(大概是通过自定义操作)?

更新时间:2022-06-21 00:52:17

像这样向你的 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\test.注意你需要在text.wxs所在的文件夹下放一个虚拟的test.msi文件来安抚wix.

Edit: The following sample test.wxs demonstrates that it works. It produces a test.msi file which installs itself to c:\program files\test. 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>