MsBuild helper for Wix auto-harvesting (using heat.exe) during build.
See role in the build process:
- In your Wix project (.wixproj) Install a NuGet package - depending on the type of a project being packaged to MSI use:
- for WPF \ Windows Forms apps: https://www.nuget.org/packages/WixAutoHarvest.ClickOnce
- for Web apps: https://www.nuget.org/packages/WixAutoHarvest.WebDeploy
- for console apps: https://www.nuget.org/packages/WixAutoHarvest.ResolveReferences
-
In your Wix project Add a reference to the project to be packaged to MSI
-
In Product.wxs add ComponentGroup include_cg to a Feature, see example:
<Feature ...>
...
<ComponentGroupRef Id="include_cg" />
</Feature>
-
[optonal] if you require any alterations to harvested file generated by heat.exe - create .xslt file and pass it in TransformFile property in your .wixproj
-
[optonal] if Platform of the target packaged project is not "Any CPU", add ReferencedProjectPlatform property to .wixproj with correct value, see example for "x86" platform:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ReferencedProjectPlatform>x86</ReferencedProjectPlatform>
...
- Clone this repo
- Get NuGet API key from your account on nuget.org
- Store API key locally:
nuget setApiKey %API_KEY% -Source https://www.nuget.org/api/v2/package
- Make changes
- Package locally by:
nuget pack
- Install locally to a Wix project (add local folder with .nupkg as NuGet feed) and test that it builds
- Once happy, package and publish by running:
nuget-pack-and-push.bat
- Automate adding of a
<Feature>
with<ComponentGroupRef Id="include_cg" />
to Product.wxs during NuGet package installation. - [BUG] Example ConsoleApplication1 won't build on a clean clone - fails with error "Unresolved reference to symbol 'WixComponentGroup:include_cg' in section 'Product:*'". However closing and reloading the whole solution helps.
- Consider using
<RefTargetDir>
from .wixproj instead of hard-coded INSTALLFOLDER. This potentially will allow to reference multiple projects to install them to separate directories. See also Rob's explanation about original harvesting feature and its use of RefTargetDir here: http://stackoverflow.com/a/15578516/902415 - Add example of XSLT for registering Windows Service, with automatic fetching of .exe file name from the AssemblyName of %(ProjectReference.Identity) as it's done in PublishReferencedProject target.