11

I'm harvesting a directory for my Visual Studio solution.

It works on my local system so far probably because the project build order is being respected.

When I run the installer on a build server it finds the right directory but it has not been created at the time of building the setup file. It throws a HEAT5052 error saying The directory 'a:\b\c' could not be found.

Is there any way to "wait" until or to execute the heat command after all project references are built?

  • 1
    Did you check whether the quoting of your directory is correct on the server? Any whitespace in your path perhaps? – mkko Dec 15 '15 at 12:36
  • Yes but that wasn't the problem. Check my post below for the answer. –  Dec 15 '15 at 13:21
  • I have been encountering the same problem; I have been able to solve it by setting an explicit build order to make sure that the setup project is truly built last. (Right-click on the project in Visual Studio, select “Build dependencies->Project dependencies”, and in the “Dependencies” page of the dialog check all projects.) – Mike Rosoft Jul 22 '19 at 11:29

2 Answers2

20

OK so I've spent hours to figure out how to fire Heat AFTER all references are resloved. I only found solutions for the <PreBuildEvent> and <PostBuildEvent> using the Heat command line and the BeforeBuild and AfterBuild targets.

So I found all kind of targets inside the wix2010.targets file located in my Program files (x86)\MSBuild\Microsoft\Wix\ folder. It contains a target called AfterResolveReferences and it does exactly that. So here's my code I ended up with (in case someone is interested):

<Target Name="AfterResolveReferences">
    <HeatDirectory
        ToolPath="$(WixToolPath)"
        OutputFile="Product.Binaries.wxs"
        SuppressFragments="$(HarvestDirectorySuppressFragments)"
        Transforms="Filter.xslt"
        Directory="$(HarvestFolder)"
        DirectoryRefId="MY_FOLDER"
        ComponentGroupName="Binaries"
        GenerateGuidsNow="true"
        SuppressRootDirectory="true"
        SuppressRegistry="true"
        PreprocessorVariable="var.App.TargetDir">
    </HeatDirectory>
</Target>
  • 8
    Thank you for this. Would you happen to know how can I glue my hair back to my head after having torn it out trying to solve this? – John Hargrove Aug 19 '19 at 19:02
0

I had the same problem and it was solved by combining the accepted answer and this answer to ensure that my post build event, which was copying files, always runs:

<RunPostBuildEvent>Always</RunPostBuildEvent> 
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>

Also, my build server was using the MSBuild command line, and I used this answer to locate my local MSBuild.exe so I could test my changes locally without having to push to the build server.

datchung
  • 3,778
  • 1
  • 28
  • 29
  • Officially supported way to locate MSBuild (answer written by me): https://stackoverflow.com/a/53319707/70345 – Ian Kemp Nov 02 '20 at 14:30