我有一个wix内置的安装程序,具有多个功能:Feature1和Feature2。在首次安装时,如果同时安装了两个功能,则将功能2删除,这将不允许正确卸载功能1。我将其范围缩小到Feature2,删除了Feature1也在使用的注册表值,导致Feature1成为广告。
Feature1和Feature2都使用通过合并模块在多个公司产品中使用的组件。这两个功能都引用了引用同一注册表值的不同合并模块。
<Feature Id="Feature1" Absent="disallow" Level="1" Title="Main Feature" AllowAdvertise="no">
<!--- Component References for Feature1 product are here ---->
<MergeRef Id="CompanyLibrary.msm" />
</Feature>
<Feature Id="Feature2" Absent="disallow" Level="1" Title="Company Library SDK" AllowAdvertise="no">
<MergeRef Id="CompanyLibrarySDK.msm" />
</Feature>
CompanyLibrary.wxs
<?define PackageId = "123..." ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Module Id="$(var.ProductShortName)" Language="1033" Version="$(var.ProductVersion)">
<Package Id="$(var.PackageId)" Manufacturer="$(var.Manufacturer)" InstallerVersion="$(var.InstallerVersion)"
Description="$(var.ProductDesc)" Comments="$(var.ProductName)" />
<Directory Id="TARGETDIR" Name="SourceDir" >
<?include ..\ProgramMenu.wxi ?>
<Directory Id="BIN" Name="bin" FileSource="..\..\Source\">
<Component Id="CompanyLibrary.dll" Guid="{1A.....}" DiskId="1" Location="local" SharedDllRefCount="yes">
<File Id="CompanyLibrary.dll" Name="CompanyLibrary" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Module>
</Wix>
CompanyLibrarySDK.wxs
<?define PackageId = "5678....." ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Module Id="$(var.ProductShortName)" Language="1033" Version="$(var.ProductVersion)">
<Package Id="$(var.PackageId)" Manufacturer="$(var.Manufacturer)" InstallerVersion="$(var.InstallerVersion)"
Description="$(var.ProductDesc)" Comments="$(var.ProductName)" />
<Directory Id="TARGETDIR" Name="SourceDir">
<?include ..\ProgramMenu.wxi ?>
<Directory Id="DocumentationFolder" Name="Documentation" FileSource="..\Documents">
<Component Id="CompanyLibrary.chm" Guid="{2B....}" SharedDllRefCount="yes" Location="local">
<File Id="CompanyLibrary.chm" Name="CompanyLibrary.chm" DiskId="1" KeyPath="yes" />
</Component>
<Component Id="Shortcut2CompanyLibrary.chm">
<RegistryValue Id="CompanyLibraryHelpReg" Root="HKCU" Key="Software\Company\Documentation\CompanyLibraryHelp" Type="string" Value="" KeyPath="yes" />
<Shortcut Id="Shortcut2CompanyLibrary"
Target="[!CompanyLibrary.chm]"
Directory="CompanyDocuments"
Name="CompanyLibrary Help File"
Show="normal" />
</Component>
</Directory>
</Directory>
</Module>
</Wix>
这是引起问题的文件:ProgramMenu.wxi
<?xml version="1.0" encoding="utf-8"?>
<Include>
<Directory Id="ProgramMenuFolder">
<Directory Id="CompanyShortcuts" Name="Company">
<Component Id="CompanyShortcuts" Guid="{999AAA...}" SharedDllRefCount="yes">
<RegistryValue Id="CompanyShortcutsReg" Root="HKCU" Key="Software\Company" Type="string" Value="" KeyPath="yes" />
<RemoveFolder Id="RemoveCompanyShortcuts" Directory="CompanyShortcuts" On="uninstall"/>
</Component>
<Directory Id="CompanyDocuments" Name="Documentation">
<Component Id="CompanyDocuments" Guid="{98765....}" SharedDllRefCount="yes">
<RegistryValue Id="CompanyDocuments" Root="HKCU" Key="Software\Company\Documentation" Type="string" Value="" KeyPath="yes" />
<RemoveFolder Id="RemoveCommonDocuments" Directory="CommonDocuments" On="uninstall"/>
</Component>
</Directory>
</Directory>
</Directory>
</Include>
仍安装Feature1但删除Feature2时,将同时删除上面设置的两个RegistryValues。我已经简化了代码很多,但是希望它仍然有意义。我是WiX的新手,试图掌握我继承的安装程序。根据我的理解,是否应该通过Windows跟踪CompanyShortcuts和CompanyDocuments组件的引用计数,或者我该怎么做才能使Windows跟踪两个组件的引用计数?