Azure-Devops 管道:无法加载文件或程序集

Azure-Devops Pipeline: Could not load file or assembly

添加对 3d 派对的引用后,我开始不断收到错误消息: 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)

在我的项目文件中,我使用的是 13 版本。

<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>

我在本地修复了这个错误:Update-Package –reinstall Newtonsoft.Json

在 Azure-Devops 上 CI Nuget 恢复步骤如下所示:

在作业日志上看到这个包正在恢复:

Restoring NuGet package Newtonsoft.Json.13.0.1

我试过Disable local cache option,没用。

我应该如何指定此步骤以强制重新安装 nuget 包?

这个问题通常通过在 web.config(或 app.config)文件中定义 bindingRedirect 来解决。

请检查这个问题here