22

Had to pick up a bit of work from another developer so just trying to wrap my head round it all!

But I'm having issues building an Azure Functions project and continuously getting a error coming form Microsoft.NET.Sdk.Functions.Build.targets , specifically unable to resolve a reference to Microsoft.Azure.WebJobs.Extensions.

So far I have attempted re-installing the Nuget Package, Re-Starting Visual Studio, my machine yada-yada.

I would welcome any suggestions and appreciate your time!

Full Error Below

Severity    Code    Description Project File    Line    Suppression State
Error       Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.WebJobs.Extensions, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
   at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)
   at Mono.Cecil.TypeReference.Resolve()
   at MakeFunctionJson.AttributeExtensions.IsWebJobsAttribute(CustomAttribute attribute)
   at MakeFunctionJson.ParameterInfoExtensions.<>c.<IsWebJobSdkTriggerParameter>b__0_0(CustomAttribute a)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at MakeFunctionJson.ParameterInfoExtensions.IsWebJobSdkTriggerParameter(ParameterDefinition parameterInfo)
   at MakeFunctionJson.MethodInfoExtensions.<>c.<HasTriggerAttribute>b__4_0(ParameterDefinition p)
   at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
   at MakeFunctionJson.MethodInfoExtensions.HasTriggerAttribute(MethodDefinition method)
   at MakeFunctionJson.MethodInfoExtensions.HasValidWebJobSdkTriggerAttribute(MethodDefinition method)
   at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable`1 types)+MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
   at MakeFunctionJson.FunctionJsonConverter.TryRun()
Error generating functions metadata
    Panmure.RiskMI.DataCollector.Functions  
benbants
  • 590
  • 7
  • 30
  • 1
    I am dealing with the same thing right now. I'll let you know if I have any breakthroughs. For me I get the error every other time I try to run the project. – Clark Aug 15 '20 at 21:28

3 Answers3

73

I saw a message when running the project saying "the extensionsmetadatagenerator package was not imported correctly" Try adding the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator nuget package to your project. It is suppose to be loaded as a dependency of Microsoft.NET.Sdk.Functions package, But I didn't see it in my project dependencies list. This worked for me.

Clark
  • 1,006
  • 8
  • 14
  • 3
    This happens when you have a version of Microsoft.NET.Sdk.Functions higher then 3.1.1, while using .NETCore3.1. The higher versions are for .NET6, however they don't return a direct error, but won't load their dependencies/NuGet packages. Your answer works, but it I prefer to downgrade Microsoft.NET.Sdk.Functions to 3.1.1. – Sam Jun 08 '22 at 13:13
  • @Sam answer is the right one for me too. Strange it didn't stop me from installing a NuGet package that clearly says net6.0 under Dependencies. – zemien Aug 24 '22 at 11:53
6

Or you can just update to

<TargetFramework>netcoreapp3.1</TargetFramework>

If you are not on 3.1

Kicasd
  • 91
  • 1
  • 4
  • 2
    This wasn't enough for me, I was already on this when I started getting this error. Adding the above-mentioned metadata generator package fixed the problem – wislon Dec 16 '21 at 00:18
0

I know this is an older post. I am using JetBrain Rider on a Mac. The only way I've gotten around this is to reinstall .Net 5 even though I am building the Function in .Net 6. Any updates that happen to .net 6 is requiring me to reinstall .net 5.

timthacker63
  • 31
  • 1
  • 7
  • Exactly the same for me with Rider on macOS. It happened when I installed .NET6, I had to install .NET5 again to make it work. And it happened now once again when I installed .NET7, same error and I had to install .NET5 (now out of support) and my .NET7 v4 Azure Functions now works. – Magnus Nov 11 '22 at 20:06