#2835 Wix library project does not support heat's HarvestProject

future
migrated
nobody
msbuild (104)
2013-08-21
2012-02-10
Anonymous
No

The Wix library project does not support heat's HarvestProject in wix2010.targets.

The ConvertReferences target has the following condition:
('$(OutputType)' == 'Package' or '$(OutputType)' == 'PatchCreation' or '$(OutputType)' == 'Module' )

Library's should be supported as well, in our case we bind files to a wix library and pass it down the chain where the c# project is no longer available but still want its outputs for an installer.

There is a discussion on this matter a year ago however I never go around to lodging a bug.
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Wix-library-project-does-not-support-heat-s-HarvestProject-in-wix2010-targets-td5940351.html

Discussion

  • Christian
    Christian
    2013-03-14

    If, for some reason, this bug cannot be fixed as desired, at least show an appropriate warning message when users try to harvest project references into WiX libraries.
    This will save one hour of valuable work time for each user stumbling upon this issue.

     
  • Christian
    Christian
    2013-03-14

    Authoring a work around

    • Copy the ConvertReferences and RefreshGeneratedFile targets from the wix200x.targets file into your WiX library project. Insert below the import of the wix targets, such that the targets override the predefined targets.

    The project will build successfully. However, there is one caveat: If the main project or other libraries also use harvesting, you will get LGHT0091 errors about duplicate symbols Product.Generated. This is because the RefreshGeneratedFile task hard codes this component id, enabling in turn WiX project templates which 'just work' with harvesting.

    So, we need to adjust this id for our project:
    - Append a task in the RefreshGeneratedFile target:

    <ItemGroup>
      <_Namespaces Include="WixNamespace">
        <Prefix>wix</Prefix>
        <Uri>http://schemas.microsoft.com/wix/2006/wi</Uri>
      </_Namespaces>
    </ItemGroup>
    <MSBuild.ExtensionPack.Xml.XmlFile
      File="@(_GeneratedFiles)"
      Namespaces="@(_Namespaces)"
      TaskAction="UpdateAttribute"
      XPath="//wix:Wix/wix:Fragment/wix:ComponentGroup"
      Key="Id"
      Value="$(MSBuildProjectName)"/>
    
    • Adjust the ComponentGroupRef in the WiX authoring to the name of the project instead of Product.Generated.
     
    Last edit: Christian 2013-03-14
  • Tamir Daniely
    Tamir Daniely
    2013-04-23

    In newer versions the ComponentGroup id is set to the generated file name without extension.
    So in order to change the ComponentGroup id to something unique, adding the following property to a property group in the project will work as intended.
    There is no need for editing the XML file directly.

    <HarvestProjectsGeneratedFile>
        $(IntermediateOutputPath)$(MSBuildProjectName).wxs
    </HarvestProjectsGeneratedFile>
    

    I also add the following property to ensure that the file gets cleaned when it should.

    <FileWrites Include="$(HarvestProjectsGeneratedFile)" />
    
     
    Last edit: Tamir Daniely 2013-04-24
  • Rob Mensching
    Rob Mensching
    2013-08-21

    • Status: open --> migrated