我有两个简单的控制台应用程序项目“Component-A”和“Component-B”,我想将它们包含在我的解决方案中的 SetupWixDemo 项目中。
在我的安装的 Wix 项目文件中,我启用了 Harvesting 项目
<PropertyGroup>
<EnableProjectHarvesting>True</EnableProjectHarvesting>
</PropertyGroup>
并使用 HeatProject 包含了这两个项目
<ItemGroup>
<HeatProject Include="..\Component-A\Component-A.csproj">
<ProjectOutputGroups>Binaries</ProjectOutputGroups>
<Link>Component-A.csproj</Link>
</HeatProject>
<HeatProject Include="..\Component-B\Component-B.csproj">
<ProjectOutputGroups>Binaries</ProjectOutputGroups>
<Link>Component-B.csproj</Link>
</HeatProject>
</ItemGroup>
它已正确生成组件 wix 文件 Generated _Component_A.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Component_A.Binaries">
<Component Id="cmpC008F1473856A259012D9243F2FAA367" Guid="*">
<File Id="fil76224611BE6FE33E8C4C1CB922BE4507" Source="$(var.Component-A.TargetDir)\Component-A.exe" />
</Component>
<Component Id="cmp8F2527F5846E0A97DD990421A1BFE039" Guid="*">
<File Id="fil2887E426D398DC77AF53475EC6CC8E82" Source="$(var.Component-A.TargetDir)\Component-A.exe.config" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Component_A.Binaries">
<ComponentRef Id="cmpC008F1473856A259012D9243F2FAA367" />
<ComponentRef Id="cmp8F2527F5846E0A97DD990421A1BFE039" />
</ComponentGroup>
</Fragment>
</Wix>
生成_Component_B.wxs
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Component_B.Binaries">
<Component Id="cmpC4EEFA1957E631623A020D230FE7FE27" Guid="*">
<File Id="fil027682CC235FE3E8DB7E93B17A690B4E" Source="$(var.Component-B.TargetDir)\Component-B.exe" />
</Component>
<Component Id="cmp5DCF4C7D83433EA092BBF18737C93FB1" Guid="*">
<File Id="filA4BD1B738072866436267073D1E70237" Source="$(var.Component-B.TargetDir)\Component-B.exe.config" />
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="Component_B.Binaries">
<ComponentRef Id="cmpC4EEFA1957E631623A020D230FE7FE27" />
<ComponentRef Id="cmp5DCF4C7D83433EA092BBF18737C93FB1" />
</ComponentGroup>
</Fragment>
</Wix>
产品.wxs
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupWixDemo" Language="1033" Version="1.0.0.0" Manufacturer="WK" UpgradeCode="60e5ca62-51b5-47d3-81b5-a36b078c88c5">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Platform="x64"/>
<MajorUpgrade DowngradeErrorMessage="A newer version of SetupWixDemo is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupWixDemo" Level="1">
<ComponentGroupRef Id="Component_A.Binaries" />
<ComponentGroupRef Id="Component_B.Binaries" />
</Feature>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />
<UIRef Id="WixUI_InstallDir" />
</Product>
<Fragment>
<SetDirectory Id="INSTALLFOLDER" Value="[WindowsVolume]Apps\WixDemo" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="SetupWixDemo" />
</Directory>
</Directory>
</Fragment>
</Wix>
我不断收到以下信息。
未解决的“片段:”部分中对符号“目录:Component_A.Binaries”的引用未解决的“片段:”部分中对符号“目录:Component_B.Binaries”的引用
我究竟做错了什么 ?
更新:
找到了解决此错误的方法。意识到我需要同时包含两个组件的目录条目
<Fragment>
<SetDirectory Id="INSTALLFOLDER" Value="[WindowsVolume]Apps\WixDemo" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="WixDemo" />
<Directory Id="Component_A.Binaries" Name="WixDemo" />
<Directory Id="Component_B.Binaries" Name="WixDemo" />
</Directory>
</Directory>
</Fragment>
虽然现在它没有安装任何东西,也没有错误。