0
votes

I am facing an issue with Azure build pipeline setup. "Build Solution" task is failing with the below error.

[error]Source\Libraries\PluginCore\PluginCore.csproj(129,5): Error MSB4036: The "ILMerge" task was not found. Check the following: 1.)

The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin" directory.

I tried to add the "ILMerge" task in build pipeline but I couldn't find any task with that name. I can't avoid using ILMerge since I have to merge the helper class dlls. Does any one come across this issue and got it resolved? Please share your inputs

1
Please provide your XML files for review.TemaTre
The task in your error message means msbuild task instead of Devops task so you can't find it in pipeline.LoLance

1 Answers

0
votes

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

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.