用WIX制作安装包
product.wxs相关问题
1、需要打包的文件,目录层级很多,文件数量也很多(甚至有几万个),没法手工写wxs安装文件
解决办法是调用heat命令行,自动生成wxs文件。
Heat.exe dir ..\..\help -cg OemHelpFilesComponents -dr OEMHELPFILESFOLDER -sreg -srd -var var.HelpFilesFolder -ag -sfrag -out HelpFile.wxs
其中OEMHELPFILESFOLDER是在product.wxs内定义的目标文件夹:
<Fragment>
<!-- http://robmensching.com/blog/posts/2010/1/26/stackoverflow-what-does-namesourcedir-refer-to/ -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLMANUFACTURERFOLDER" Name="$(var.ProductManufacturer)">
<Directory Id="INSTALLFOLDER" Name="$(var.ProductName)">
<Directory Id="INSTALLPROGRAMFOLDER" Name="Program"/>
<Directory Id="INSTALLPREFERENCESFOLDER" Name="Preferences"/>
<Directory Id="OEMFOLDER" Name="OEM">
<Directory Id="OEMRESDLLSFOLDER" Name="ResDLLs"/>
<Directory Id="OEMHELPFILESFOLDER" Name="help"/>
</Directory>
</Directory>
</Directory>
</Directory>
<Directory Id="DesktopFolder" Name="Desktop"></Directory>
</Directory>
</Fragment>
HelpFilesFolder需要在预定义内事先定义:
<DefineConstants>HelpFilesFolder=$(SolutionDir)..\help;DeployResDLLsFolder=$(SolutionDir)..\..\deploy\ResDLLs;</DefineConstants>
且var.HelpFilesFolder会成为wxs文件内的路径起始:
2、打包文件超过2GB,light报错算术运算符溢出(light.exe(0,0): error LGHT0001: 算术运算导致溢出)
解决办法是在product内,MediaTemplate的EmbedCab 设置为no,具体代码如下:
<Product
Id="*"
Name="$(var.ProductName) MSI"
Language="2052"
Version="$(var.ProductVersion)"
Manufacturer="$(var.ProductManufacturer)"
UpgradeCode="f2b48580-bab4-487b-a9a6-931ac1ec602b"
>
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="no"/>
<Feature Id="ProductFeature" Title="XXXSetup" Level="1">
<ComponentGroupRef Id="ProductProgramComponents" />
<ComponentGroupRef Id="ProductShortcuts" />
</Feature>
<InstallExecuteSequence>
<Custom Action='CustomAction1' Before='InstallFinalize'>NOT Installed</Custom>
<Custom Action='CustomAction2' After='InstallFinalize'>NOT Installed</Custom>
</InstallExecuteSequence>
</Product>
这样的话,就会在输出目录下除了生成MSI或exe以外,还会生成很多cab文件,如下所以:
bundle.wxs相关问题
待续…