azure-webjobs-sdk: Cannot build functions with .NET 6 on macOS

Hi,

I’m getting this fatal error at build time when using the .NET 6 previews:

error : Metadata generation failed. Exit code: ‘137’ Error: ‘Failed to initialize CoreCLR, HRESULT: 0x80004005’

/Users/johnkors/.nuget/packages/microsoft.azure.webjobs.script.extensionsmetadatagenerator/1.2.0/build/Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(37,5): warning : Failed to initialize CoreCLR, HRESULT: 0x80004005 [/Users/johnkors/kode/blank/fplbot-org/fplbot/src/FplBot.Functions/FplBot.Functions.csproj]
/Users/johnkors/.nuget/packages/microsoft.azure.webjobs.script.extensionsmetadatagenerator/1.2.0/build/Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(37,5): error : Metadata generation failed. Exit code: '137' Error: 'Failed to initialize CoreCLR, HRESULT: 0x80004005' [/Users/johnkors/kode/blank/fplbot-org/fplbot/src/FplBot.Functions/FplBot.Functions.csproj]

Not sure if it’s on your end or the .NET SDK team…?

OS: macOS .NET SDK : .NET 6 Preview 7 ( 6.0.100-preview.7.21379.14 ) TFM: netcoreapp3.1 Microsoft.NET.Sdk.Functions Version 3.0.13

csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
  </ItemGroup>
...
$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.7.21379.14
 Commit:    22d70b47bc

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.5
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/

Host (useful for support):
  Version: 6.0.0-preview.7.21377.19
  Commit:  91ba01788d

.NET SDKs installed:
  2.1.806 [/usr/local/share/dotnet/sdk]
  3.1.103 [/usr/local/share/dotnet/sdk]
  3.1.300 [/usr/local/share/dotnet/sdk]
  5.0.100 [/usr/local/share/dotnet/sdk]
  5.0.102 [/usr/local/share/dotnet/sdk]
  5.0.200 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.5.21302.13 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.6.21355.2 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.7.21379.14 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.18 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.5.21301.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.7.21378.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.18 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.7.21377.19 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 7
  • Comments: 36 (4 by maintainers)

Most upvoted comments

Yep, this is still an issue with RTM, not only previews / RCs. Updated to title of this ticket to reflect it. The only 2 possible resolutions I’ve found:

  1. 🛠 Re-install .NET 5 SDK AFTER installing .NET 6. This will rollback the dotnet exec launcher to a .NET 5 version that works. Run this, to verify you use a 5.0 launcher:

➜ strings /usr/local/share/dotnet/dotnet | grep “@(#)” @(#)Version 5.0.1221.52207 @Commit: 7211aa01b34bb55ca67bdddd6e80ce23ee201bd2

  1. 🔥 Remove all dotnet folders, SDKS and runtimes. Just burn it (sudo rm -rf /usr/local/share/dotnet/ ). Then install .NET 6 (NB! Only works 100% if you are on the latest Microsoft.Azure.Functions.* nugets, which it looks like you are)

It’s actually not that easy to reproduce. I even tried with a macOS agent in a GitHub action with the exact same SDKs, and it built fine.

The only common denominator I found is with the sequence in which you install which SDK version matters (which I could not work out how to in a GitHub action).

The installer team looked at it here: https://github.com/dotnet/installer/issues/11951

Recommend reading what their take on it is.

I’m really unsure if this is with the functions SDK or with the installer in general, but finally just accepted it as a odd error with the 2 workarounds provided above.

And a +1 on @RichMercer comment. The same issue of “Failed to initialize CoreCLR, HRESULT: 0x80004005’” applies to Microsoft.NET.Sdk.Functions.Worker.Sdk as well.