'Azure-Devops Pipeline: Could not load file or assembly

After adding a reference to 3d party I started keep getting an error: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

In my proj file I'm using 13 version.

<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>

Locally I fixed this error with: Update-Package –reinstall Newtonsoft.Json

On Azure-Devops CI Nuget restore step look like this: enter image description here

On Job log is see that this package is restoring:

Restoring NuGet package Newtonsoft.Json.13.0.1

I tried Disable local cache option, it doesn't work.

How I should specify this step to force reinstall nuget package?



Solution 1:[1]

This issue is typically fixed by defining bindingRedirect in your web.config (or app.config) file(s).

Please check this question here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alberto Maghini