wixtoolset / issues

WiX Toolset Issues Tracker
http://wixtoolset.org/
130 stars 24 forks source link

HarvestDirectory fails with cannot find System.Runtime #7124

Open BryanCrotaz opened 1 year ago

BryanCrotaz commented 1 year ago

Bugs

If this issue is a bug:

4.0.0-rc.1

Visual Studio 2022

Using wixproj

.Net 6.0

Use HarvestDirectory

<HarvestDirectory Include="$(SolutionDir)\AgentWorkerService\bin\x64\Release\net6.0">
      <DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
      <ComponentGroupName>HarvestedComponents</ComponentGroupName>
      <SuppressRootDirectory>True</SuppressRootDirectory>
      <VerboseOutput>True</VerboseOutput>
    </HarvestDirectory>

Every file fails with:

heat.exe : warning HEAT5151: Could not harvest data from a file that was expected to be an assembly: 
C:\PathToProject\bin\x64\Release\net6.0\NetEscapades.Extensions.Logging.RollingFile.dll. 
If this file is not an assembly you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: 
Could not load file or assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
The system cannot find the file specified.

Failed to run heat.exe, can't find System.Runtime (using an old version)

barnson commented 1 year ago

You can suppress assembly harvesting by setting SuppressRegistry to true.

Leaving open to make a better error message.

BryanCrotaz commented 1 year ago

But isn't the whole point of running the harvest to pick up all the assemblies in the folder? Why would I want to suppress that?

barnson commented 1 year ago

Setting SuppressRegistry to true suppresses registry harvesting, not the file harvesting.

BryanCrotaz commented 1 year ago

I'm getting the error report for every assembly in the directory. Why would this be related to the registry?

barnson commented 1 year ago

Because registry harvesting loads the assembly.

BryanCrotaz commented 1 year ago

Silly question, why is it called registry harvesting and not assembly harvesting?

And if I suppress it, won't that mean that my assemblies are ignored?

barnson commented 1 year ago

It will still generate File authoring.

BryanCrotaz commented 1 year ago

Ok this needs some documentation as to what Registry Harvesting actually does.

You've said disabling it will stop assembly harvesting but file harvesting still happens.

Sounds like this should be named FileHarvest and AssemblyHarvest instead.

However I'm completely confused as to what the difference is. From a packaging point of view assemblies are files. And why the word registry in there? I'm not giving it any registry keys to start from and it doesn't seem to be creating registry keys on the windows target machine. So the name doesn't make sense.

barnson commented 1 year ago

Assemblies can generate registry entries (see, e.g., regasm).

BryanCrotaz commented 1 year ago

This definitely needs better documentation. None of this is covered.

And no clue why running harvest causes it to load a version of System.Runtime that I'm not using.

https://wixtoolset.org/docs/v3/msbuild/target_reference/harvestdirectory/

6bee commented 6 days ago

Just stumbled over the same error using HeatFile where setting SuppressRegistry="true" did not help.

I'm using WixToolset.Sdk/5.0.2.

heat.exe : error HEAT5151: Could not harvest data from a file that was expected to be an assembly: mylibrary.dll. If this file is not an assembly you can ignore this warning. Otherwise, this error detail may be helpful to diagnose the failure: Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.