Azure-functions-vs-build-sdk: Azure Function .NetCore 3.0 doesn't support .NetStandard 2.1 so could not use EntityFrameworkCore 3.0 which requires it

Created on 3 Oct 2019  路  9Comments  路  Source: Azure/azure-functions-vs-build-sdk

Hi guys,

As the title suggested, my team is having a lot of troubles to underpin the dependencies these days.

Microsoft.NET.Sdk.Functions 1.29.0:
image

Microsoft.EntityFrameworkCore 3.0.0:
image

Microsoft.EntityFrameworkCore.Cosmos 3.0.0:
image

I have tried to downgrade everything to .NetStandard 2.0, but still because of the sub reference of the Microsoft.Extensions.DependencyInjection, so the recent preview versions will not work with Microsoft.Azure.Functions.Extensions which only supports 2.2.0:
image

This is now a dead-end for us, if we want to EntityFrameworkCore.Cosmos. Could you please give updates on when it will supports .NetStandards 2.1 and when the dependency injection extension will be upgraded to support a higher version of Microsoft.Extensions.DependencyInjection. It will affect our decision about whether to use azure functions and architecture decisions.

Most helpful comment

I'm seeing a similar issue using version 1.0.30-beta2. If my Function uses a type from a .NET Standard 2.1 library in its signature, building the project fails. It looks like the failure is because build tasks in Microsoft.NET.Sdk.Functions need to be able to load types from Function signatures, but it can't load types from .NET Standard 2.1 assemblies.

Will the Microsoft.NET.Sdk.Functions package be updated to target .NET Core 3.0 soon?

Build error:

Microsoft (R) Build Engine version 16.4.0-preview-19502-03+3af680463 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 23.94 ms for C:\Users\mikerou\source\repos\FunctionApp3\ClassLibrary1\ClassLibrary1.csproj.
  Restore completed in 45.59 ms for C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
  ClassLibrary1 -> C:\Users\mikerou\source\repos\FunctionApp3\ClassLibrary1\bin\Debug\netstandard2.1\ClassLibrary1.dll
  FunctionApp3 -> C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\bin\Debug\netcoreapp3.0\bin\FunctionApp3.dll
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeMethodInfo.GetParameters() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo method) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo method, String& error) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable`1 types)+MoveNext() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryRun() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Error generating functions metadata [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Metadata generation failed. [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]

Build FAILED.

Repro steps:

  1. Create a v3 preview Functions project
  2. Create a .NET Standard 2.1 library
  3. Update the Function in the v3 Functions project to return a Task<ActionResult<Class1>> where Class1 comes from the .NET Standard 2.1 library.
  4. Build and observe the error. Note that if the class library targets .NET Standard 2.0, instead, everything builds and runs fine.

All 9 comments

I'm seeing a similar issue using version 1.0.30-beta2. If my Function uses a type from a .NET Standard 2.1 library in its signature, building the project fails. It looks like the failure is because build tasks in Microsoft.NET.Sdk.Functions need to be able to load types from Function signatures, but it can't load types from .NET Standard 2.1 assemblies.

Will the Microsoft.NET.Sdk.Functions package be updated to target .NET Core 3.0 soon?

Build error:

Microsoft (R) Build Engine version 16.4.0-preview-19502-03+3af680463 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 23.94 ms for C:\Users\mikerou\source\repos\FunctionApp3\ClassLibrary1\ClassLibrary1.csproj.
  Restore completed in 45.59 ms for C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj.
  You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview
  ClassLibrary1 -> C:\Users\mikerou\source\repos\FunctionApp3\ClassLibrary1\bin\Debug\netstandard2.1\ClassLibrary1.dll
  FunctionApp3 -> C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\bin\Debug\netcoreapp3.0\bin\FunctionApp3.dll
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeMethodInfo.GetParameters() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.MethodInfoExtensions.GetDisabled(MethodInfo method) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.MethodInfoExtensions.HasUnsuportedAttributes(MethodInfo method, String& error) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable`1 types)+MoveNext() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryRun() [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Error generating functions metadata [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :  [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]
C:\Users\mikerou\.nuget\packages\microsoft.net.sdk.functions\1.0.30-beta2\build\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Metadata generation failed. [C:\Users\mikerou\source\repos\FunctionApp3\FunctionApp3\FunctionApp3.csproj]

Build FAILED.

Repro steps:

  1. Create a v3 preview Functions project
  2. Create a .NET Standard 2.1 library
  3. Update the Function in the v3 Functions project to return a Task<ActionResult<Class1>> where Class1 comes from the .NET Standard 2.1 library.
  4. Build and observe the error. Note that if the class library targets .NET Standard 2.0, instead, everything builds and runs fine.

I'm also seeing the above issue mentioned by @mjrousos with 1.0.30-beta2 as well.

I'm also seeing the above issue mentioned by @mjrousos & @diegostamigni with 1.0.30-beta2 as well.

@jiaweihuo18 - Were you ever able to find a workaround?

@a-vishar there isn't really something we can do about this, the dependencies are just wrong when targeting netcore3 and netstandard2.1

You can see from the screenshot below how WebJob has dependency on AspNetCore 2.2 rather than 3.0 plus others are wrong as well.. all mixed up :)

image

So we can just wait and hope they will go ahead and fix this stuff.

As far as I can see, the packages you screenshotted should all be compatible with .NET Core 3.0 by way of .NET Standard. Which package, in particular, are you saying is incorrect?

So it's impossible to use Entity Framework with Azure Functions v3 (at least currently)... 馃檮 (?)

Certainly seems that way, at least that is my conclusion after about 2 hours of troubleshooting

Was this page helpful?
0 / 5 - 0 ratings