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

时间:2016-02-24 08:02:54

标签: wix wix3.10

实际上我刚开始从http://wixtoolset.org/documentation/

开始学习wix 在阅读并学习了一些东西后,我有信心开始创建我的第一个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

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

1 个答案:

答案 0 :(得分:0)

感谢大家,实际上我通过做一些更改并进行实验来实现它,并且更新了工作代码:

肯定是的,如果有人有更好的方法,那么请发表你的答案......

<?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>