6

I'm trying to use the HarvestDirectory project element in WiX 4, Preview 1, and finding it pretty unintuitive. I can't seem to get it to actually do anything obvious, even though I'm following the breadcrumbs in the documentation. In WiX 3, I used the command-line tools directly and could generate component entries that way, but that doesn't appear to be the practice in version 4, so it would be nice if this actually worked.

Here's a project file, more-or-less as per the docs:

<Project Sdk="WixToolset.Sdk/4.0.0-preview.1">
  <PropertyGroup>
    <HarvestFileSuppressUniqueIds>false</HarvestFileSuppressUniqueIds>
    <HarvestFileGenerateGuidsNow>true</HarvestFileGenerateGuidsNow>
  </PropertyGroup>
  <ItemGroup>
    <HarvestDirectory Include="files">
      <ComponentGroupName>maincomponent</ComponentGroupName>
      <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>          
      <SuppressRootDirectory>true</SuppressRootDirectory>
    </HarvestDirectory>
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Wixtoolset.Heat" />
  </ItemGroup>
</Project>

The WiX markup looks basically like this:

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
    <Package Name="thing" Manufacturer="maker of thing" Version="1.0.0.0" UpgradeCode="c5a29143-303d-40bb-9a3b-0c207a80d8a8">
      <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />
      <Feature Id="mainfeature">
        <ComponentGroupRef Id="maincomponent" />
      </Feature>
    </Package>
    <Fragment>
      <StandardDirectory Id="ProgramFiles64Folder">
        <Directory Id="dir1" Name="dir1">
          <Directory Id="dir2" Name="dir2">
            <Directory Id="INSTALLFOLDER" Name="installfolder" />
          </Directory>
        </Directory>
      </StandardDirectory>
    </Fragment>
</Wix>

I just assumed that the ComponentGroupName in the project would somehow (magically) line up with the ComponentGroupRef in the wxs file, but instead I get an error:

error WIX0094: The identifier 'WixComponentGroup:maincomponent' could not be found. Ensure you have typed the reference correctly and that all the necessary inputs are provided to the linker.

Adding the component group explicitly to the wxs fixes the build, but results in an empty installer.

I'm sure HarvestDirectory does something, or other, but what is not exactly clear.

jamesm
  • 71
  • 6

2 Answers2

2

Check that you actually have a reference to Heat extension package in your project (I had issues with adding that package and saw same behaviour):

<PackageReference Include="WixToolset.Heat" Version="4.0.0-preview.1" />
Woodman
  • 1,108
  • 9
  • 11
  • Thanks; yes, that was the problem. I wasn't including the version. – jamesm Dec 14 '22 at 13:13
  • I had a variation on this issue - I had the package included, but somehow it had resolved as 0.0.0 - I had to remove and re-add the package, then use msbuild verbose build to discover that it was not finding any files and so skipping my target...hopefully helps someone. – smaudet Mar 01 '23 at 07:25
0

I have come across another variant which results in the same error message with WixToolset.Heat Version 4.0.0.

In my case, I specified a sub-folder in the Include attribute using \ (backslash) which gave me the same error WIX0094. I fixed it by replacing all \ (backslashs) with / (slash). It seems like slash is the only supported separator.

For example:

<HarvestDirectory Include="Folder\SubFolder"> (WRONG)

<HarvestDirectory Include="Folder/SubFolder"> (CORRECT)

Lucas
  • 373
  • 1
  • 9