Skip to content

Setup using HeatDirectory task kills Visual Studio 2022 #6636

@henning-krause

Description

@henning-krause
  • Which version of WiX are you building with?

WiX Toolset v3.11

  • Which version of Visual Studio are you building with (if any)?

Visual Studio 2022

  • Which version of the WiX Toolset Visual Studio Extension are you building with (if any)?

1.0.0.12

  • Which version of .NET are you building with?

.NET 4.8

  • Describe the problem and the steps to reproduce it.

I'm trying to build my installer using MSBUild 17.0.0.52104 (Visual Studio 2022) from the Visual Studio. My setup includes this extra build target:

 <Target Name="BeforeBuild">
    <HeatDirectory AutogenerateGuids="true" SuppressRegistry="true" SuppressCom="true" SuppressRootDirectory="true" DirectoryRefId="ServiceRoot" SuppressFragments="true" PreprocessorVariable="var.DISTFOLDER" Transforms="TransformHeat.xslt" ComponentGroupName="ApplicationFiles" OutputFile="Files.wxs" Directory="$(DistFolder)" ToolPath="$(WixToolPath)" />
  </Target>

This successfully runs with MSBuild from VS 2019 (x86), but crashes with MSBuild from VS2022 (x64) with this exception:

BeforeBuild:
  C:\Program Files (x86)\WiX Toolset v3.11\bin\Heat.exe dir "..\..\build\src" -cg ApplicationFiles -dr ServiceRoot -scom -sreg -srd -var var.DISTFOLDER -ag -sfrag -t TransformHeat.xslt -out Files.wxs
  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.
     at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
     at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
     at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
     at System.Reflection.Assembly.LoadFrom(String assemblyFile)
     at Microsoft.Tools.WindowsInstallerXml.Build.Tasks.WixToolTask.ExecuteToolThread(Object parameters)

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.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Tools.WindowsInstallerXml.Build.Tasks.WixToolTask.ExecuteToolThread(Object parameters)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)

Now, I fixed this by adding the attribute RunAsSeparateProcess="true" to the HeatDirectory task (as described in (#2570).

I just wanted to bring this issue to attention, because it kills Visual Studio 2022 reliably every time I build the setup if the RunAsSeparateProcess is not set to true.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions