这段时间,用Wix做公司的安装包,因为网上相关的完整资料还是很少,所以做这些工作还是让我有好几天比较受累。为了让自己以后不再受累,也为了让后来者少点付出,多点收获,写此文以记之。
背景:
要做一个安装包,安装包里是一个虚拟磁盘管理系统;但是要同时自动适应不同的操作系统window2000; NT;XP;Window7;Window7 x64等。
Product.wxs 代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include $(var.ProjectDir)\Includes\Variables.wxi ?>
<Product Id="83597389-1402-4F66-8130-75A21546E8DA" Name="XX资源管理器插件" Language="1033" Version="1.0.0.0" Manufacturer="XXXXX科技(深圳)有限公司"
UpgradeCode="3FE94C9F-3E39-46BB-AD97-D3AC6016B48A">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)">
<Directory Id="INSTALLLOCATION" Name="$(var.ProgramFileFolderName)" >
<Directory Id="FileSystem1" Name="VHSyndesign 6.0 Client" />
</Directory>
</Directory>
<Directory Id="$(var.PlatformSystemFolder)">
<Directory Id="SystemDrivers" Name="drivers" />
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="FileSystemMenu" Name="$(var.ProgramFileFolderName)" />
</Directory>
</Directory>
<DirectoryRef Id="FileSystemMenu">
<Component Id="ApplicationShortcut" Guid="60494ab4-c90a-4fe4-b6da-79d64b3efa43">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="XX资源管理器插件"
Description="XX资源管理器插件"
Target="[FileSystem1]VHSoftFS.exe"
WorkingDirectory="FileSystem1"/>
<!-- Step 1: Add the uninstall shortcut to your installer package -->
<Shortcut Id="UninstallProduct"
Name="卸载XX资源管理器插件"
Description="卸载XX资源管理器插件"
Target="[System64Folder]msiexec.exe"
Arguments="/x [ProductCode]"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\VHSoft\MyApplicationName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Upgrade Id="{3FE94C9F-3E39-46BB-AD97-D3AC6016B48A}">
<UpgradeVersion Minimum="1.0.0" Property="NEWERPRODUCTFOUND" OnlyDetect="yes" IncludeMinimum="yes" />
</Upgrade>
<CustomAction Id="MounterDokan" ExeCommand="[FileSystem1]dokanctl.exe /i a" Directory="FileSystem1" Execute="deferred" Return="check"/>
<CustomAction Id="UnMounterDokan" ExeCommand="[FileSystem1]dokanctl.exe /r a" Directory="FileSystem1" Return="check"/>
<InstallExecuteSequence>
<Custom Action="MounterDokan" After="InstallFiles" >NOT Installed</Custom>
<Custom Action="UnMounterDokan" Before="RemoveFiles">Installed AND NOT REINSTALL</Custom>
</InstallExecuteSequence>
<Feature Id="ProductFeature1" Title="WixDokan" Level="1" ConfigurableDirectory="INSTALLLOCATION" >
<ComponentGroupRef Id="CG_FS.NT"/>
<ComponentGroupRef Id="CG_FS.Win7x86"/>
<ComponentRef Id="ApplicationShortcut"/>
</Feature>
<UI>
<UIRef Id="WixUI_Mondo" />
<UIRef Id="WixUI_ErrorProgressText" />
</UI>
</Product>
</Wix>