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
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" />
Indeed like Tobias was mentioning, removing below line in de csproj solved the error.
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.9" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With