WiX将文件添加到目录组件

时间:2013-05-31 22:49:37

标签: wix

我参与了WiX并且添加注册表项工作得很好,所以我在添加文件时遇到了麻烦。

我收到错误:

Found orphaned Component 'ProductComponent'.  
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.

工作代码:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">

        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="ChrisExcelAddintest" />

    <Component Id="Registry_FriendlyName">
      <RegistryValue Id="RegKey_FriendlyName" Root="HKCU"
                     Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn1test"
                     Name="ChrisFriendlyName"
                     Value="My Excel Add-In"
                     Type="string" KeyPath="yes" />
    </Component>
    <Component Id="Registry_Description">
      <RegistryValue Id="RegKey_Description" Root="HKCU"
                     Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn1test"
                     Name="Description"
                     Value="Chris Excel Add-In"
                     Type="string" KeyPath="yes" />
    </Component>
    <Component Id="Registry_Manifest">
      <RegistryValue Id="RegKey_Manifest" Root="HKCU"
                     Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn1test"
                     Name="Manifest" Value="[INSTALLFOLDER]ExcelAddIn1test.vsto|vstolocal"
                     Type="string" KeyPath="yes" />
    </Component>
    <Component Id="Registry_LoadBehavior">
      <RegistryValue Id="RegKey_LoadBehavior" Root="HKCU"
                     Key="Software\Microsoft\Office\Excel\AddIns\ExcelAddIn1test"
                     Name="LoadBehavior" Value="3"
                     Type="integer" KeyPath="yes" />
    </Component>
        </Directory>
    </Directory>
</Fragment>

但是我尝试添加以下代码RIGHT AFTER

 <Directory Id="TARGETDIR" Name="SourceDir">

此代码:

 <Directory Id="ProgramMenuFolder">
        <Directory Id="installcalc">
          <Component Id="ProductComponent" Guid="b11556a2-e066-4393-af5c-9c9210187eb2">
            <File Id="Calc" DiskId="1" Source="C:\WINDOWS\system32\calc.exe"/>
          </Component>
        </Directory>
    </Directory>

1 个答案:

答案 0 :(得分:15)

您需要将您的组件添加到“功能”部分

e.g。

<Feature Id="ProductFeature" Title="yourtitle" Level="1">
   EXISTING ENTRIES HERE, Your new entry below
  <ComponentRef Id="ProductComponent2"/>
</Feature>