WiX项目: - 如何减少EXE(Bootstapper)大小

时间:2016-04-11 05:27:32

标签: winforms wix installer

嗨我有两个MSI一个用于86位,一个用于64位,每个MSI大小为60 MB,所以我想用两个MSI创建exe(Bootstrapper),exe大小为60-70 MB。

问题: - 目前我的exe(Bootstrapper)大小为120 MB我想用两个Msi将其减少到60-70 MB

我的代码

在Bootstrapper中

<Chain>
      <PackageGroupRef Id="NetFx451Web"/>
      <ExePackage SourceFile="vstor_redist.exe" Vital="yes" Cache="yes" Compressed="no" Permanent="yes" 

                  InstallCommand="/q /norestart" 
                  RepairCommand="/q /norestart" 
                  UninstallCommand="/q /norestart" 
                  DetectCondition="VSTOR40" 
                   />
      <ExePackage SourceFile="vcredist_x86.exe" Vital="yes" Cache="yes" Compressed="no" Permanent="yes" 
                  DownloadUrl="http://downloads.mangoapps.com/pre/win/vcredist_x86.exe"
                  InstallCommand="/q /norestart" 
                  RepairCommand="/q /norestart" 
                  UninstallCommand="/q /norestart" 
                  DetectCondition="VCREDIST2012" 
                   />      
        <MsiPackage Id="MSI64" SourceFile="$(var.WixMFW_PerMachine.ProjectDir)bin\64\Release\MFWSetup_x64.msi" InstallCondition="(VersionNT64)" DisplayInternalUI="no">
          <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]"/>
        </MsiPackage>      
        <MsiPackage Id="MSI86" SourceFile="$(var.WixMFW_PerMachine.ProjectDir)bin\86\Release\MFWSetup_x86.msi" InstallCondition="(NOT VersionNT64)" DisplayInternalUI="no">
          <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]"/>
        </MsiPackage>
    </Chain>

IN MSI

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
  <Product Id="*" Name="Demo $(var.bitness)" Language="1033" Version="$(var.SetupVersionNumber)" Manufacturer="Demo " UpgradeCode="$(var.UpgradeCode)">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <CustomAction Id="DIRCA_TARGETDIR" Property="TARGETDIR" Value="[LocalAppDataFolder][Manufacturer]\[ProductName]" Execute="firstSequence" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of Demo For Windows is already installed." />
    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Maximum="$(var.SetupVersionNumber)" Property="OLDPRODUCTFOUND" OnlyDetect="no" IncludeMinimum="yes" IncludeMaximum="no" Language="1033" />
      <UpgradeVersion Minimum="$(var.SetupVersionNumber)" Property="NEWPRODUCTFOUND" OnlyDetect="yes" IncludeMinimum="no" Language="1033" />
    </Upgrade>


    <?if $(var.Configuration) = ReleaseMSI ?> 
    <Media Id="1" Cabinet="Cab1.cab" EmbedCab="yes"></Media>
    <?if $(var.Platform) = x64 ?> 
    <Media Id="2" Cabinet="Cab2.cab" EmbedCab="yes"></Media>
    <?else ?> 
    <Media Id="3" Cabinet="Cab3.cab" EmbedCab="yes"></Media>
    <?endif ?> 
    <?else?> 
    <Media Id="1" Cabinet="Cab1.cab" EmbedCab="no"></Media>
    <?if $(var.Platform) = x64 ?> 
    <Media Id="2" Cabinet="Cab2.cab" EmbedCab="no"></Media>
    <?else ?> 
    <Media Id="3" Cabinet="Cab3.cab" EmbedCab="no"></Media>
    <?endif ?> 
    <?endif ?> 

Feature 
Directory 
Component example 
-- 
 <Component Id="comp_F7B6C4FB_A2AD_493C_8081_8DAC3298503B" Guid="156DA224-3EC3-490C-8BE4-192E93883F44" Permanent="no" SharedDllRefCount="no" Transitive="no"  Win64="$(var.Win64)" >
        <File Id="_93649A69_3915_4B81_B0CB_B0AB2807E6E6" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="CefSharp.dll" Source="..\Utility\externalReferences\CefSharp.dll" KeyPath="yes" />
      </Component>
--- 
Registrys 

  </Fragment>
</Wix>

但这不起作用..请帮助我。

所有文件都是x86和x64 MSI中的comman唯一不同的是

 <?if $(var.Platform) = x64 ?>
          <Component Id="SQLite" Win64="$(var.Win64)">
            <File Id="SQLite.Interop" Source="$(var.ExternalReferences)\x64\SQLite.Interop.dll" KeyPath="yes" DiskId="2"/>
          </Component>
          <Component Id="System.Data.SQLitecomp" Win64="$(var.Win64)">
            <File Id="System.Data.SQLite" Source="$(var.ExternalReferences)\x64\System.Data.SQLite.dll" KeyPath="yes" DiskId="2"/>
          </Component>
  <?else ?>
          <Component Id="SQLite86" Win64="$(var.Win64)">
            <File Id="SQLite.Interop" Source="$(var.ExternalReferences)\x86\SQLite.Interop.dll" KeyPath="yes" DiskId="3"/>
          </Component>
          <Component Id="System.Data.SQLitecomp" Win64="$(var.Win64)">
            <File Id="System.Data.SQLite" Source="$(var.ExternalReferences)\x86\System.Data.SQLite.dll" KeyPath="yes" DiskId="3"/>
          </Component>

1 个答案:

答案 0 :(得分:2)

建议创建三个MSI:

  1. 将所有公共文件安装到平台的常见文件MSI 独立位置,例如CommonAppDataFolder
  2. 安装64位SQLLite文件的x64平台MSI。
  3. 安装32位SQLLite文件的x86平台MSI。
  4. 然后,您可以将Bootstrapper更改为始终安装MSI#1以及MSI#2或MSI#3,具体取决于平台。由于公共文件不再重复,因此应减少Bootstrapper的整体大小。

    <Chain>
      <PackageGroupRef Id="NetFx451Web"/>
      <ExePackage SourceFile="vstor_redist.exe" Vital="yes" Cache="yes" Compressed="no" Permanent="yes" 
    
                  InstallCommand="/q /norestart" 
                  RepairCommand="/q /norestart" 
                  UninstallCommand="/q /norestart" 
                  DetectCondition="VSTOR40" 
                   />
      <ExePackage SourceFile="vcredist_x86.exe" Vital="yes" Cache="yes" Compressed="no" Permanent="yes" 
                  DownloadUrl="http://downloads.mangoapps.com/pre/win/vcredist_x86.exe"
                  InstallCommand="/q /norestart" 
                  RepairCommand="/q /norestart" 
                  UninstallCommand="/q /norestart" 
                  DetectCondition="VCREDIST2012" 
                   />      
        <MsiPackage Id="MSICommon" SourceFile="$(var.WixMFW_PerMachine.ProjectDir)bin\Release\MFWSetup_common.msi" DisplayInternalUI="no">
          <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]"/>
        </MsiPackage>      
        <MsiPackage Id="MSI64" SourceFile="$(var.WixMFW_PerMachine.ProjectDir)bin\64\Release\MFWSetup_x64.msi" InstallCondition="(VersionNT64)" DisplayInternalUI="no">
          <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]"/>
        </MsiPackage>      
        <MsiPackage Id="MSI86" SourceFile="$(var.WixMFW_PerMachine.ProjectDir)bin\86\Release\MFWSetup_x86.msi" InstallCondition="(NOT VersionNT64)" DisplayInternalUI="no">
          <MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]"/>
        </MsiPackage>
    </Chain>