C# 预编译的Azure函数依赖项错误

C# 预编译的Azure函数依赖项错误,c#,azure,visual-studio-2017,azure-functions,C#,Azure,Visual Studio 2017,Azure Functions,我正在构建一个简单的web钩子函数,它使用C#Resource Manager API对Azure资源进行一些操作。生成失败,原因是: .nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Vers

我正在构建一个简单的web钩子函数,它使用C#Resource Manager API对Azure资源进行一些操作。生成失败,原因是:

.nuget\packages\microsoft.net.sdk.functions\1.0.2\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(31,5): error : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
我已经检查过了,一切都在运行Newtonsoft.Json 9.0.1。我猜这是由于我的Nuget软件包中的一些不匹配,但不确定如何挖掘

我有:

  • Microsoft.Azure.Management.ResourceManager 1.6.0-preview
  • Microsoft.NET.Sdk.Functions 1.0.2
  • Microsoft.Rest.ClientRuntime.Azure.Authentication 2.3.1


使用VS2017 15.3.3

可以归结为预览资源管理器包

  • Microsoft.Azure.Management.ResourceManager 1.6.0-preview
因为这是开源的,所以我去了GitHub项目并查看了它。实际上,它需要一个特定版本的NewtonSoft。我通过将使用资源管理器API的代码放入一个程序集中并使用该程序集来修复我的问题。这在Azure功能中现在可以正常工作。

简而言之,查看依赖项,将它们隔离在程序集中,然后将其包含在项目中。

是否尝试安装更高版本的Newtonsoft.Json并降级到版本Newtonsoft.Json 9.0.1?我们还可以从路径C:\Users\username\.nuget\packages\Microsoft.NET.Sdk.Functions\1.0.2\Build\netstandard1.0获取Microsoft.NET.Sdk.Functions.Build.targets文件。然后我们可以得到更多关于这个的信息。你是否查看了文件“packages.config”来验证没有对旧版本的引用?还可以查看根项目文件夹下的“packages”目录,看看是否存在任何旧版本。您还可以查看项目中的引用:右键单击Newtonsoft.Json并检查其中的版本以验证它不是旧版本。
using System.Collections.Generic;  
using System.Net;  
using Newtonsoft.Json;  
using System.Net.Http;  
using System.Threading.Tasks;  
using Microsoft.Azure.Management.ResourceManager;  
using Microsoft.Azure.Management.ResourceManager.Models;  
using Microsoft.Azure.WebJobs;  
using Microsoft.Azure.WebJobs.Host;  
using Newtonsoft.Json.Linq;  
using Microsoft.Rest.Azure.Authentication;