One of our developers is currently building an Azure Function app in .Net 6.0 using Visual Studio 2022 Preview on Windows 10.
The solution has several projects, 1 Azure Function and several class libraries. It fails to run with:
Metadata generation failed. Exit code: '-2147450750' Error: 'Failed to load the dll from [C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0\hostpolicy.dll], HRESULT: 0x800700C1An error occurred while loading required library hostpolicy.dll from [C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.0.0]' DATA.Services.CompaniesQuery.Function C:\Users\r_ver.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\4.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets 37
Microsoft.NETCore.App is using version 6.0.1 and is listed until Solution Explorer in the Azure Function project in Dependencies > Frameworks > Microsoft.NETCore.App.
We have tried the following:
Reinstalling .Net 6 SDK
Reinstalled VS 2022 version 17.0.5
Laptop restart
Deleted contents of "C:\Users\someuser.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator" folder.
C:\Program Files\dotnet\shared\Microsoft.NETCore.App has folder for .Net Core 2.0.0 and 6.0.1
The error relates to 2.0.0 however no references are made to this in the project including csproj files.
Is a manual update required to the targets file? Currently not aware of any resolution to this.
CodePudding user response:
I have tried in my environment and it works as expected,
To build an Azure Function app in .Net 6.0 using Visual Studio 2022 Preview(17.0.5) on Windows 10.
Below are the steps which i have followed:
- Installed latest version
- Allowed firewall setting
OUTPUT:-
NOTE:-
When installing Azure function core tools version, make sure that we have installed only one core tool version on our computer.
.net 6 supports Azure function runtime version 4x only.
For more information please refer this Microsoft Documentation: Azure Functions runtime versions overview



