Advanced Harvesting gathers resources from MSBuild project references, folders and self-registration to generate .wxs code that installs those resources. Advanced Harvesting takes great care to organize the harvested resources according to the Windows Installer's best practices
Harvesting is controlled by extension elements, <HarvestProject/>
and <HarvestFolder/>
. To get started with Advanced Harvesting add the FgwepExtension.wixext.dll
extension--via Add Reference Dialog in your .wixproj--then add the http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd
namespace to your root <Wix/>
element. For example,
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:fg="http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd">
Next, add the desired extension element to a <Component/>
. The parent element will act as the template for the harvesting. Let's look at a very simple example. Consider a SetupProject1.wixproj with a project reference to ConsoleApplication1.csproj which in turn has a project reference to ClassLibrary1.csproj. Let's add ConsoleApp.wxs that will install the ConsoleApplication1.exe and its references:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:fg="http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd">
<Fragment>
<ComponentGroup Id="ConsoleAppComponents">
<Component Directory="INSTALLFOLDER">
<fg:HarvestProject Name="ConsoleApplication1"
OutputGroup="BuiltProjectOutputGroup;BuiltProjectOutputGroupDependencies" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
During the build of SetupProject1.wixproj, Advanced Harvesting will find the <HarvestProject/>
element and expand the results to .wxs code functionally equivalent to:
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:fg="http://www.firegiant.com/schemas/v3/wxs/fgwep.xsd">
<Fragment>
<ComponentGroup Id="ConsoleAppComponents">
<Component Directory="INSTALLFOLDER">
<File Source="path\to\ConsoleApplication1.exe" />
<File Source="path\to\ConsoleApplication1.exe.config" />
</Component>
<Component Directory="INSTALLFOLDER">
<File Source="path\to\ClassLibrary1.dll" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
Notice that Advanced Harvesting included the .exe.config in the Component with the .exe it configures. This organization of resources makes the .exe the a versioned KeyPath for the Component. The versioned KeyPath provides an implicit version for the unversioned .exe.config so the two files will be installed, upgraded and repaired together. See the Strategy attribute documentation for alternative Component organizations supported by Advanced Harvesting and when to use them.