Hangfire
Hangfire copied to clipboard
Failed to resolve assembly: Newtonsoft.Json when using ILRepack.Lib.MSBuild.Task
Hi there -- I am encountering the following error when trying to use the Hangfire.Core and ILRepack.Lib.MSBuild.Task NuGet libraries. Can someone please assist me with this issue? Thanks.
Error:
Failed to resolve assembly: 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
Steps to Reproduce:
- Download the ~5KB CS Project file: HangfireILRepack.zip
- Perform a Debug Build – notice that after pulling the NuGet libraries, it works.
- Perform a Release Build – notice the error mentioned above.
There's an open issue regarding this, please see https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task/issues/26. The simplest solution would be to create and reference the ILRepack.targets in the project directory with the following contents:
<Project>
<Target Name="ILRepacker" AfterTargets="Build" Condition="$(Configuration.Contains('Release'))">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/>
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Newtonsoft.Json'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Hangfire.Core'" />
<InputAssemblies Include="@(ReferencePathWithRefAssemblies)" Condition="'%(filename)' == 'Owin'" />
</ItemGroup>
<ILRepack
Parallel="true"
DebugInfo="true"
AllowDuplicateResources="false"
InputAssemblies="@(InputAssemblies)"
TargetKind="SameAsPrimaryAssembly"
KeyFile="$(KeyFile)"
OutputFile="$(OutputPath)$(TargetName)$(TargetExt)"
/>
</Target>
</Project>