Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to resolve assembly: Newtonsoft.Json when using ILRepack.Lib.MSBuild.Task #2448

Open
testsys-murali opened this issue Sep 27, 2024 · 1 comment

Comments

@testsys-murali
Copy link

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:

  1. Download the ~5KB CS Project file: HangfireILRepack.zip
  2. Perform a Debug Build – notice that after pulling the NuGet libraries, it works.
  3. Perform a Release Build – notice the error mentioned above.
@testsys-murali testsys-murali changed the title Failed to resolve assembly: Newtonsoft.Json Failed to resolve assembly: Newtonsoft.Json when using ILRepack.Lib.MSBuild.Task Sep 27, 2024
@odinserj
Copy link
Member

There's an open issue regarding this, please see ravibpatel/ILRepack.Lib.MSBuild.Task#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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants