Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Wix) heat.exe could not be loaded with msbuild

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,

like image 601
Sebastian Avatar asked Jan 03 '23 12:01

Sebastian


1 Answers

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

like image 132
kuch3n Avatar answered Jan 12 '23 18:01

kuch3n