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,
Since msbuild runs as a 64bit exe, it will fail to load the 32bit heat.exe. To fix this issue, processes have to run seperately. This can be done by adding this to a PropertyGroup:
<RunWixToolsOutOfProc Condition=" '$(PROCESSOR_ARCHITECTURE)'!='x86' ">true</RunWixToolsOutOfProc>
But thats not enough. Heat does successfully ignore that Property. Instead you have to use the Property RunAsSeparateProcess
:
<HeatDirectory
....
RunAsSeparateProcess="$(RunWixToolsOutOfProc)" />
See: https://github.com/wixtoolset/issues/issues/2467#issuecomment-736519622
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With