【问题标题】:Is it possible to get out of this Nuget Hell scenario?是否有可能摆脱这种 Nuget Hell 情景?
【发布时间】:2018-10-04 00:56:45
【问题描述】:

我希望我的项目有以下包

  • Microsoft.Azure.ServiceBus
  • Microsoft.Azure.WebJobs.Extensions
  • Microsoft.Azure.WebJobs.Extensions.Storage
  • Microsoft.Azure.WebJobs.ServiceBus
  • Microsoft.NET.Sdk.Functions
  • .NET 标准库
  • Newtonsoft.Json

现在我有最新的版本

  • Microsoft.Azure.ServiceBus (3.1.1)
  • Microsoft.Azure.WebJobs.Extensions (3.0.0)
  • Microsoft.Azure.WebJobs.Extensions.Storage (3.0.0)
  • Microsoft.Azure.WebJobs.ServiceBus (v3.0.0-beta8)
  • Microsoft.NET.Sdk.Functions (1.0.22)
  • .NET 标准库 (2.0.1)
  • Newtonsoft.Json(11.0.2)

其中有以下WebJobs的依赖:

  • Microsoft.Azure.ServiceBus [无]
  • Microsoft.Azure.WebJobs.Extensions [Microsoft.Azure.WebJobs (>= 3.0.0)]
  • Microsoft.Azure.WebJobs.Extensions.Storage [Microsoft.Azure.WebJobs (>= 3.0.0)]
  • Microsoft.Azure.WebJobs.ServiceBus [Microsoft.Azure.WebJobs (= 2.2.0)]
  • Microsoft.NET.Sdk.Functions [Microsoft.Azure.WebJobs (>= 3.0.0 &&
  • .NETStandard 库 [无]
  • Newtonsoft.Json [无]

有趣的是,Visual Studio 并未将此标记为问题(解决方案资源管理器中没有黄色三角形),即使存在明显冲突的版本要求。当我尝试构建我的 Function App 项目时,出现错误

严重性代码描述项目文件行抑制状态 错误 System.IO.FileNotFoundException:无法加载文件或 程序集'Microsoft.Azure.WebJobs,版本=3.0.0.0,文化=中性, PublicKeyToken=null' 或其依赖项之一。系统无法 找到指定的文件。文件名:'Microsoft.Azure.WebJobs, 版本=3.0.0.0,文化=中性,PublicKeyToken=null' 在 System.ModuleHandle.ResolveType(RuntimeModule 模块, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack 类型)在 System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) 在 System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) 在 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord、MetadataImport 范围、Assembly 和 lastAptcaOkAssembly、 RuntimeModule 装饰模块,MetadataToken 装饰令牌, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] 属性,IList 派生属性,运行时类型和属性类型, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) 在 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule 装饰模块,Int32 装饰元数据令牌,Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) 在 System.Reflection.CustomAttribute.GetCustomAttributes(运行时参数信息 参数,RuntimeType caType) 在 System.Attribute.InternalParamGetCustomAttributes(ParameterInfo 参数, 类型类型,布尔继承)在 MakeFunctionJson.ParameterInfoExtensions.GetDisabledAttribute(ParameterInfo 参数信息)在 System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() 在 System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)
at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo method) at MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo method, String& error) at MakeFunctionJson.FunctionJsonConverter.<GenerateFunctions>d__9.MoveNext() at System.Collections.Generic.List
1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable
1 源) 在 MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
在 MakeFunctionJson.FunctionJsonConverter.TryRun()

警告:程序集绑定日志记录已关闭。启用程序集绑定 失败记录,设置注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 为 1。注意:有 是与装配绑定失败相关的一些性能损失 记录。要关闭此功能,请删除注册表值 [HKLM\Software\Microsoft\Fusion!EnableLog]。

错误生成函数元数据

有什么办法可以摆脱这个 Nuget 地狱,或者我不能使用所有这些包吗?我试过查看以前的版本,但似乎没有办法让他们都同意 WebJobs 的版本。通常如何解决这些情况?

【问题讨论】:

    标签: c# azure nuget azure-functions nuget-package


    【解决方案1】:

    删除Microsoft.Azure.WebJobs.ServiceBus,新包现在称为Microsoft.Azure.WebJobs.Extensions.ServiceBus(3.0.0)。请参阅 v2 函数中的 package references

    另外,Microsoft.NET.Sdk.Functions(1.0.22) 包含Newtonsoft.Json(11.0.2)Microsoft.Azure.WebJobs.Extensions (3.0.0),无需单独安装。并且Microsoft.Azure.WebJobs.Extensions.ServiceBus(3.0.0)也包含Microsoft.Azure.ServiceBus(3.0.2),只要不是最新版本就不需要安装。

    比如你可以在VS中创建一个v2 servicebus触发器模板,只需要添加Microsoft.Azure.WebJobs.Extensions.Storage (3.0.0)就可以达到你的目的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-15
      • 2016-02-20
      相关资源
      最近更新 更多