15

I'm trying to update Azure Function from 3.1 to .Net 5. I am following the below article https://codetraveler.io/2021/02/12/creating-azure-functions-using-net-5/

I created a new Time Triggered Function version 3.1 and followed the above article

After completing all the required steps, rebuild gives below error

Severity Code Description Project File Line Suppression State Error MSB4062 The "GenerateFunctionMetadata" task could not be loaded from the assembly C:\Users\schudasam.nuget\packages\microsoft.net.sdk.functions\3.0.11\build..\tools\netcoreapp3.1\Microsoft.NET.Sdk.Functions.MSBuild.dll. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. XYZ.Functions C:\Users\schudasam.nuget\packages\microsoft.azure.functions.worker.sdk\1.0.1\build\Microsoft.Azure.Functions.Worker.Sdk.targets 38

Tools : Visual Studio 2019

Visual Studio Project ScreenShot

EDIT

We postponed upgrading to .Net 5. Will leave the question here as others might have similar issue. Wouldn't be able to try the suggestions, hope it helps others. Thank you for suggesting solutions everyone. Please upvote the solutions that works for you

Sid.Hart
  • 151
  • 1
  • 5
  • Could you please check if azure functions in the solution were referencing to different sdk version and if there is any misspelled tags? Also please check https://github.com/Azure/azure-functions-vs-build-sdk/issues/128#issuecomment-337711852 ( Similar issue while upgrading) – JayaChatterjee-MSFT Mar 31 '21 at 17:07
  • @JayaChatterjee-MSFT I tried the github solution, didn't work, Azure function is referencing .Net 5 Currently we postponed upgrading to .Net 5. But will leave the question here if anyone else has the issue, and someone finds a solution. – Sid.Hart Apr 15 '21 at 16:12
  • 1
    Removing the reference to Microsoft.NET.Sdk.Functions seems to do the trick for me – Tobias Apr 19 '21 at 07:40

2 Answers2

13

Indeed like Tobias was mentioning, removing below line in de csproj solved the error.

<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.9" />
Rob Aerts
  • 131
  • 4
10

Thanks to one of my colleague, the error is pointing to a reference from dotnetcore 3.1 which is wrong, it should be referenced from dotnet 5, try doing the following in your .csproj file

Replace the following

PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.3" OutputItemType="Analyzer" />

with

    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk.Analyzers" Version="1.0.0" />

or remove the same package from your solution explorer under the packages of your project and add it via the nuget manager.

Edit:

If you are following the article to the point then to be replaced package reference is following

<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.0.0-preview3" OutputItemType="Analyzer" />