是否有可能摆脱这种 Nuget 地狱场景?

Is it possible to get out of this Nuget Hell scenario?

我希望我的项目有以下包

现在我有最新的版本

其中具有以下 WebJobs 依赖项:

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

Severity Code Description Project File Line Suppression State Error System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'Microsoft.Azure.WebJobs, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType) at System.Attribute.InternalParamGetCustomAttributes(ParameterInfo param, Type type, Boolean inherit) at MakeFunctionJson.ParameterInfoExtensions.GetDisabledAttribute(ParameterInfo parameterInfo) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)<br> 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.List1..ctor(IEnumerable1 collection)<br> at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Error generating functions metadata

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

删除 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)就可以达到你的目的