'Could not load file or assembly' error when calling Heat (WiX) from within MSBuild
Has anyone seen this before?
I have an VS solution with a WiX project, which in turn has a <HeatDirectory> MSBuild taks ('HeatDirectory' is a WiX built-in MSBuild taks). Running my AppVeyor build locally (i.e. running locally the same PowersShell script that is run by AppVeyor) everything works as expected, However, on AppVeyor I get the following error:
[00:02:00] Project "C:\projects\tfscmdlets\TfsCmdlets\TfsCmdlets.Setup\TfsCmdlets.Setup.wixproj.metaproj" (2) is building "C:\projects\tfscmdlets\TfsCmdlets\TfsCmdlets.Setup\TfsCmdlets.Setup.wixproj" (4) on node 1 (default targets).
[00:02:00] BeforeBuild:
[00:02:00] C:\Program Files (x86)\WiX Toolset v3.9\bin\Heat.exe dir C:\projects\tfscmdlets\TfsCmdlets\\TfsCmdlets\Bin\Release -cg ModuleComponent -dr INSTALLDIR -scom -sreg -srd -var var.SourceDir -ag -out obj\Release\_ModuleComponent_dir
[00:02:00] .wxs
[00:02:00] Could not load file or assembly 'file:///C:\Program Files (x86)\WiX Toolset v3.9\bin\Heat.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format.
[00:02:01] at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boo
[00:02:01] lean forIntrospection, Boolean suppressSecurityChecks)
[00:02:01] at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound,
[00:02:01] Boolean forIntrospection, Boolean suppressSecurityChecks)
[00:02:01] at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection
[00:02:01] , Boolean suppressSecurityChecks)
[00:02:01] at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCraw
[00:02:01] lMark& stackMark)
[00:02:01] at System.Reflection.Assembly.LoadFrom(String assemblyFile)
[00:02:01] at Microsoft.Tools.WindowsInstallerXml.Build.Tasks.WixToolTask.ExecuteToolThread(Object parameters)
[00:02:01] Error: 8/3/2015 5:41:17 PM:
[00:02:01] At C:\projects\tfscmdlets\TfsCmdlets\psake-default.ps1:70 char:12 + exec { MSBuild.exe '--%' $MSBuildArgs }
When I saw the "An attempt was made to load a program with an incorrect format" error message, I assumed it could be a case of bitness mismatch (MSBuild x64 loading a WiX x86 assembly or vice-versa) but after checking the PATH env var in the build server it seems not to be the case: MSBuild is listed as 'C:\Program Files (x86)\MSBuild\12.0\Bin' in PATH, so, I guess it is x86. Same applies to WiX, located at C:\Program Files (x86)\WiX Toolset v3.9.
Well, I ran out of guesses :)
Does anyone have an idea on why it's broken?
AppVeyor project: https://ci.appveyor.com/project/igoravl/tfscmdlets/
GitHub repo: https://github.com/igoravl/tfscmdlets
Thanks in advance,
Igor
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

1 Posted by igoravl on 03 Aug, 2015 07:57 PM
Adding some further information: after collecting Fusing binding logs, it seems MSBuild is running as x64 (notice line below, "Running under executable C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe", pointing to Framework64 folder):
How do I force MSBuild x86 to be used? I tried to set env var Platform to x86, to no avail. After googling for a while, it seems that invoking a x86 PowerShell would do the trick too, but I couldn't find a way to instruct AppVeyor to use a x86 PowerShell.
Any ideas?
Support Staff 2 Posted by Feodor Fitsner on 03 Aug, 2015 10:04 PM
Have you tried adding something like:
3 Posted by igoravl on 03 Aug, 2015 11:03 PM
Feodor, thanks for following up. I found a workaround, though I don't quite understand whtá going on.
My wixproj file has these two imports:
For some reason it's resolving to #1, even though it's running under MSBuild x64. By disabling the first line (thus forcing x64) it now works.
Thanks for the help. If I eventually find anything else I'll post it here for the record, in case others have the same issue.
Cheers,
Igor
Support Staff 4 Posted by Feodor Fitsner on 03 Aug, 2015 11:07 PM
OK, thanks for the update!
Ilya Finkelshteyn closed this discussion on 25 Aug, 2018 01:58 AM.