构建 Wix 项目时出现孤立组件错误

orphaned component error when building wix project

实际上我今天才开始学习wix http://wixtoolset.org/documentation/

阅读和学习一些东西后,我有信心开始创建我的第一个 wix 项目,相同的配置在这里:

<?xml version="1.0" encoding="UTF-8"?>
   <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

     <Product Id="*" Name="PersonalDailyInstaller" Language="1033" Version="1.0.0.0"
       Manufacturer="Muhammad Sufiyan Shaikh" UpgradeCode="1327de13-b713-4cee-9778-be9c7460c0aa">
     <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
     <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

     <MediaTemplate />
     <!-- <MediaTemplate EmbedCab="yes" /> -->

    <Feature Id="ProductFeature" Title="PersonalDailyInstaller" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>
  </Product>

  <Fragment>

     <Directory Id="TARGETDIR" Name="SourceDir">
       <Directory Id="ProgramFilesFolder">
          <Directory Id="INSTALLFOLDER" Name="PersonalDaily" />
       </Directory>
     </Directory>

     <DirectoryRef Id="INSTALLFOLDER">
        <Component Id="MainExe" Guid="D7DC3991-2EE4-4BE5-B8B4-D15AC05592F3">
           <File Id="MainExe" Source="bin\Debug\PersonalDaily.exe" KeyPath="yes" Checksum="yes"/>
        </Component>
        <Component Id="DataPD" Guid="9DF21E80-F608-416A-BBAE-92AB3DA4CAE6">
           <File Id="DataPD" Source="bin\Debug\data.PD" KeyPath="yes" Checksum="yes"/>
        </Component>
     </DirectoryRef>

   </Fragment>

   <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
         <Component Id="ProductComponent">
           <File Source="$(var.PersonalDaily.TargetPath)" />
         </Component>
      </ComponentGroup>
  </Fragment>
</Wix>

现在当我构建 wix 项目时出现以下错误:

Severity Code Description Project File Line Suppression State Error Found orphaned Component 'MainExe'. If this is a Product, every Component must have at least one parent Feature. To include a Component in a Module, you must include it directly as a Component element of the Module element or indirectly via ComponentRef, ComponentGroup, or ComponentGroupRef elements. PersonalDailyInstaller C:\Users\muham\documents\visual studio 2015\Projects\PersonalDaily\PersonalDailyInstaller\Product.wxs 25

任何帮助或解决方法对我来说都是一个很大的帮助。提前致谢。

谢谢大家,实际上我是通过对它进行一些更改和试验让它工作的,更新后的工作代码在这里:

当然可以,如果有人有更好的方法,那么请 post 你的回答...

<?xml version="1.0" encoding="UTF-8"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

 <Product Id="*" Name="PersonalDailyInstaller" Language="1033" Version="1.0.0.0"
   Manufacturer="Muhammad Sufiyan Shaikh" UpgradeCode="1327de13-b713-4cee-9778-be9c7460c0aa">
 <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
 <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

 <MediaTemplate />
 <!-- <MediaTemplate EmbedCab="yes" /> -->

<Feature Id="ProductFeature" Title="PersonalDailyInstaller" Level="1">
  <ComponentGroupRef Id="ProductComponents" />
  <ComponentGroupRef Id="Dlls" />
</Feature>
</Product>

<Fragment>

 <Directory Id="TARGETDIR" Name="SourceDir">
   <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="PersonalDaily" />
   </Directory>
 </Directory>

 <ComponentGroup  Id="Dlls"  Directory="INSTALLFOLDER">
    <Component Id="DataPD" Guid="9DF21E80-F608-416A-BBAE-92AB3DA4CAE6">
       <File Id="DataPD" Source="..\PersonalDaily\bin\Debug\data.PD" KeyPath="yes" Checksum="yes"/>
    </Component>
 </ComponentGroup>

</Fragment>

<Fragment>
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
     <Component Id="ProductComponent">
       <File Source="$(var.PersonalDaily.TargetPath)" />
     </Component>
   </ComponentGroup>
 </Fragment>
</Wix>