Skip to content

Function.json generation failed (MetaGeneration) #5786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cboudereau opened this issue Mar 11, 2020 · 5 comments · Fixed by #5791
Closed

Function.json generation failed (MetaGeneration) #5786

cboudereau opened this issue Mar 11, 2020 · 5 comments · Fixed by #5791
Assignees

Comments

@cboudereau
Copy link

Check for a solution in the Azure portal

After updating the Microsoft.NET.Sdk.Functions to 3.0.5 cleaning then building the project, an error occurs. I think the issue is connected to #4390 :

Investigative information

Function App version : V3, dotnet core 3.1

Repro steps

  1. Create a new function
  2. Use Custom routes with custom attributes
  3. build the project

Expected behavior

Expected the function.json without msbuild errors.

Actual behavior

A build error is displayed :

Severity	Code	Description	Project	File	Line	Suppression State
Error		Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.Azure.WebJobs.Extensions.Http, Version=3.0.2.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
	Gds.AzureFunctions	C:\Users\Clément\.nuget\packages\microsoft.net.sdk.functions\3.0.4\build\Microsoft.NET.Sdk.Functions.Build.targets	41	

Known workarounds

Pin the version of the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator package to 1.1.5

@ghost ghost assigned mhoeger Mar 11, 2020
@cboudereau
Copy link
Author

cboudereau commented Mar 12, 2020

If it can help, I analyzed the reason and after debugging with Mono.Cecil, the bin project directory contains the missed assembly in version 1.1.5 but not in 1.1.6.

After patching the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets by reverting the AfterTargets attribute from Build to _GenerateFunctionsPostBuild (Line 42, Target named _GenerateFunctionsExtensionsMetadataPostBuild), the assembly is available and Mono.Cecil finds the assembly.

Hi @brettsam, the targets fix (f987062) causes a potential regression here.

How can I help to solve this problem ?

@brettsam
Copy link
Member

Can you share your project file? This is a known issue with 1.1.6 if you're directly referencing ExtensionsMetadataGenerator. but that should be very rare (there's no need to directly reference; the Sdk references it for you).

@cboudereau
Copy link
Author

cboudereau commented Mar 12, 2020

Hi @brettsam, first of all, thank you for your quick reply, I appreciate it.

I am not using directly this reference, I only reference the main package Microsoft.NET.Sdk.Functions.

The problem appears when you update the package, all inter dependencies are updated and the version 1.1.6 of the package Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator is used.

When you say it is a well known issue of the 1.1.6, would it be possible to have the issue number please so that we can contribute too ?

@brettsam
Copy link
Member

I'm not seeing this when I use 3.0.5 -- would you still mind sharing your csproj file so I can try to repro this?

It's a known issue in the sense that I called it out during my commit to 1.1.6 -- we were having bigger issues so I thought that this was an okay risk for now (not assuming anyone using the Sdk would hit 1.1.6 unless they added a direct ref).

So let's use this issue as the tracking item for that.

@cboudereau
Copy link
Author

Here is the repo where you can reproduce the problem : https://github.com/cboudereau/azurefunctionsample

I added the workaround in comments to quickly analyse the main differences between both versions

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants