Skip to content

Commit

Permalink
Handle architecture mismatch to avoid crashing host
Browse files Browse the repository at this point in the history
Fixes: wixtoolset/issues#6636

MSBuild typically handles exceptions thrown directly by tasks and reports them as errors. WixToolTask.ExecuteTool, however, is forking its execution onto another thread and this thread is throwing when invoking Heat directly in-proc. This is crashing its host. This is wixtoolset#15 of all crashes in Visual Studio 17.3.

Handle the error and give a helpful message instead of crashing.
  • Loading branch information
davkean committed Oct 14, 2022
1 parent 6b46136 commit a4d4f13
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/tools/WixTasks/WixToolTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ private void ExecuteToolThread(object parameters)
Assembly toolAssembly = Assembly.LoadFrom((string)pathAndArguments[0]);
this.exitCode = (int)toolAssembly.EntryPoint.Invoke(null, new object[] { pathAndArguments[1] });
}
catch (BadImageFormatException bife)
{
Log.LogError("Unable to load tool from path {0} due to architecture mismatch. Consider setting the RunAsSeparateProcess parameter to $(RunWixToolsOutOfProc).", bife.FileName);
this.exitCode = -1;
}
catch (FileNotFoundException fnfe)
{
Log.LogError("Unable to load tool from path {0}. Consider setting the ToolPath parameter to $(WixToolPath).", fnfe.FileName);
Expand Down

0 comments on commit a4d4f13

Please sign in to comment.