7

When using MSBuild.ILMerge.Task referenced via packagereference the following error came up:

error MSB4018: The "MSBuild.ILMerge.Task" task failed unexpectedly.
error MSB4018: System.IO.FileNotFoundException: Cannot find ILMerge 
executable.
error MSB4018:    at MSBuild.ILMerge.Task.LoadILMerge()
error MSB4018:    at MSBuild.ILMerge.Task.Execute()
error MSB4018:    at error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

This is because the MSBuild.ILMerge.Task.dll can't find the ILMerge executable in its package location. I guess the main reason of this may be the different folder structure between package.config and PackageReference.

Has anyone else had this issue? Any help is appreciated in advance

Devesh Kumar Singh
  • 20,259
  • 5
  • 21
  • 40
Demian
  • 81
  • 1
  • 3

2 Answers2

2

You could try downgrading ILMerge to 2.14.1208.

This solved it for me.

https://github.com/emerbrito/ILMerge-MSBuild-Task/issues/13

  • Useful feedback, the upgrade from ILMerge 2.14.1208 to 3.X also broke MsBuild.ILMerge.Task for me, I have reverted back. – Zach Mast Jun 10 '19 at 21:20
0

I had the same problem. In my case it arose due to the following reasons (related to some updates in my Nuget packages):

  • sometimes I had few conditions in my project files to handle Nuget packages. When ever I updated my Nuget packages, these project files were updated and all my conditions were overwritten. I found this issue by using diff tools in Git and add my conditions manually then everything was working fine.
  • Again sometimes I need to update my Nuget packages (my solution includes multiple dependent projects, so I need to update my Nuget packages when I build a new version). If I forgot to commit my changes in Git (including package.config and project files) the same issues appeared (in release mode).
amirfg
  • 272
  • 2
  • 6
  • 21