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.