Error MSB4036: The "ILMerge" task was not found.
I tried to add the "ILMerge" task in build pipeline but I couldn't
find any task with that name.
The task here mean msbuild tasks instead of devops tasks, they're different things. The error message indicates you call a task named ILMerge
in project file(xx.csproj) while this task is not defined or can't be found.
Check Msbuild Task Reference here and we can find ILMerge
task is not a Predefined Task from msbuild. For this, if you have this content in your project file:
<Target Name="Test" AfterTargets="build">
<Message Text="Test starts..." Importance="high" />
<ILMerge /> <!--This is the direct cause of your issue.-->
</Target>
You'll now get:
![enter image description here](https://i.stack.imgur.com/8yrzo.png)
To resolve that error message:
You should remove the <ILMerge ... />
in line129 of PluginCore.csproj
. Or you have to make sure you have corresponding assembly referenced in your project file, so that you can use the ILMerge task from that assembly.
See Task writing, one msbuild task is actually one class that implements ITask interface or derive from Task class.So if you have one custom or third-party assembly which defined the ILMerge task(class) in code, you can still use the task. Then your issue could result from that you don't add that assembly into course control or restore the nuget package that contains the assembly successfully.
There are many nuget packages that may contain ILmerge-related task, like one, two, three.
1.If you don't have any custom assembly that contains ILMerge
, then it's expected behavior to get that error since it's not predefined task. You can check the nuget packages above to do IlMerge job.
2.If that build works well locally, only get the issue in Devops pipeline. Then make sure you've restored the nuget package that contains the assembly(the dll that defines ILMerge class) before build task. Or make sure you've added the assembly in source control(not recommended) if you don't use nuget package way.