Azure-functions-host: MetadataGenerator fails to discover internal IWebJobsStartup types during build on netcoreapp2 project

Created on 2 Nov 2018  路  12Comments  路  Source: Azure/azure-functions-host

Create a new Function App project, which should default to netcoreapp2 with the latest bits.
Create a class and wire up an IWebJobsStartup class and build.

using FunctionApp35;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Hosting;

[assembly: WebJobsStartup(typeof(MyStartup))]

namespace FunctionApp35
{
    public class MyStartup : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
        }
    }
}

It should be generating an extensions.json file in the build output, that contains the class -- but it's stopped working. This does work if the project is netstandard2.

Most helpful comment

This version of the package is now released: https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator/1.0.2.

If you add 1.0.2 as a nuget reference, your extensions.json should be generated now, no matter which framework you are targeting.

Edit: If you're moving forward to 1.0.2 directly, we've found an issue with that process: https://github.com/Azure/azure-functions-vs-build-sdk/issues/277

Edit 2: Instead of referencing ExtensionsMetadataGenerator 1.0.2 directly, please move Microsoft.Net.Sdk.Functions forward to 1.0.25. This will include the generator update.

All 12 comments

We got the same issue

Is using netstandard2.0 and pinning the version to 2.0.12246 the best workaround for now?

Can you try using netcoreapp2.0 as your platform (with no pinning)? And a fix is coming soon...

This version of the package is now released: https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator/1.0.2.

If you add 1.0.2 as a nuget reference, your extensions.json should be generated now, no matter which framework you are targeting.

Edit: If you're moving forward to 1.0.2 directly, we've found an issue with that process: https://github.com/Azure/azure-functions-vs-build-sdk/issues/277

Edit 2: Instead of referencing ExtensionsMetadataGenerator 1.0.2 directly, please move Microsoft.Net.Sdk.Functions forward to 1.0.25. This will include the generator update.

I just switched my project back from targetting netstandard2.0 to netcoreapp2.2, but even without this new package installed it seems to be working fine. So I'm a little confused as to whether I need to install this package or not.

In fact, it looks like the extensions.json is correctly generated during build, but is not copied to the output folder when using dotnet publish. I've been using this workaround, but I was under the impression that wasn't necessary anymore with this package?

I've not seen that workaround before, so I can't speak to that. But you shouldn't need to do anything special anymore with this new package. I'm not sure why it would be working without it, as it was pretty broken when targeting anything other than a 2.0 framework. Have you tried a full clean and build?

But, in general, if it works, that's good :-)

We'll be moving the Microsoft.NET.Sdk.Functions package to depend on this new ExtensionsMetadataGenerator version soon, so you'll get the new package anyway if you ever move that package forward.

Interesting, because what I'm seeing is that it doesn't work, unless apply the workaround I mentioned. I see the extensions.json being generated when doing dotnet build (either Debug or Release), but when doing dotnet publish the output folder does not contain the extensions.json?

And this happens both with and without ExtensionsMetadataGenerator 1.0.2 being referenced?

Sorry, should have mentioned that. Yes, it seems to do that both with or without.

@jmezach -- would you possible be able to try the solution here? https://github.com/Azure/azure-functions-host/pull/4059. I'm trying to determine if this is going to fix a whole bunch of problems of if we've got more lurking behind this.

Okay, so what I said before wasn't entirely correct. The extensions.json is being generated, but in the out/bin folder when doing dotnet publish -c Release -o out (it was just being hidden by VS Code). Unfortunately the generated file isn't complete. For example, it does list the Durable Functions extension, but it doesn't list my own Startup class. So I tried adding this to my Functions project file:

<PropertyGroup>
  <_IsFunctionsSdkBuild>true</_IsFunctionsSdkBuild>
</PropertyGroup>

But that doesn't seem to fix the issue. Only applying the Directory.Build.targets file workaround I described earlier seems to fix the issue for me.

Also, it might be worth mentioning that I'm doing this on a Mac with the latest azure-functions-core-tools installed.

Thanks @jmezach. This sounds like a separate issue (mostly since it also happens with 1.0.1). I've opened https://github.com/Azure/azure-functions-host/issues/4133 to track. I'll work with you over there to try to get a repro and fix going. Thanks!

Was this page helpful?
0 / 5 - 0 ratings