预编译的Azure函数依赖性错误

时间:2017-08-29 23:26:50

标签: 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, 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
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;    

使用VS2017 15.3.3

1 个答案:

答案 0 :(得分:0)

这一切都归结为预览资源管理器包。

  • Microsoft.Azure.Management.ResourceManager 1.6.0-preview

由于这是开源我去了GitHub项目并检查了它。基本上归结为需要特定版本的NewtonSoft。我通过将使用资源管理器API的代码放入一个程序集中来修复我的问题,并使用它。现在,这在Azure功能中可以正常使用 简而言之,查看依赖项,将它们隔离在程序集中,然后将其包含在项目中。