I have an issue with heat.exe
as soon as I build my project in MSBuild
. I get this error message:
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files (x86)\WiX Toolset v3.11\bin\Heat.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I have looked up a possible solution on stackoverflow here: Referred links
I've tryed to change my configuration in all sorts of ways but can't get a hold of what is missing.
This is how I have configured right now. I want to be able to target both x64 and x86 platform.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>..\..\BuildArtifacts\SetupProjects\Myproject</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>..\..\BuildArtifacts\SetupProjects\Myproject</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Release</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>..\..\BuildArtifacts\SetupProjects\Myproject</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>..\..\BuildArtifacts\SetupProjects\Myproject</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Release</DefineConstants>
</PropertyGroup>
Any help appreciated,
UPDATE: There seems to be a closed issue in WiX's issues database which you should check out first of all. Please check if the problem description is reminiscent of what you experience: https://github.com/wixtoolset/issues/issues/2467
It seems to relate to 64-bit MSBuild - and the exception is the same as you describe. Maybe read comments from the bottom up - there is a recent comment at the bottom from 2017.
My naive first thought is whether you can run the 32-bit MSBuild instead? (I don't know much about this). Or as mentioned in the bottom comment in the linked issue, run the executable as an external process?
Old Answer: The first thing that comes to mind: I believe heat.exe
has problems with 64-bit COM files. Do you have any of those in your project? Just mentioning it, there is probably another cause (as well). Maybe try to test by removing the COM files and run a build - if possible.
I believe this issue is also still there. I don't know much about it, but I've been informed that FireGiant's commercial kit (in other words not free) handles advanced harvesting with 64-bit files.