question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot build functions with .NET 6 on macOS

See original GitHub issue

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]

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:35 (4 by maintainers)

github_iconTop GitHub Comments

22reactions
johnkorscommented, Nov 9, 2021

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)
2reactions
johnkorscommented, Nov 10, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot debug net6.0-macos Apps - Developer Community
When I hit debug, the following error is shown in the Terminal: Possible reasons for this include: * You misspelled a built-in dotnet...
Read more >
.NET 6 and M1 problems when other SDKs are present in ...
Run Rider, go to File | Settings | Build, Execution, Deployment | Toolset and Build and choose proper dotnet CLI (x64 or ARM...
Read more >
Not able to run Azure functions in VS code in mac?
NOTE:- To run function locally based on the given MICROSOFT DOCUMENTATION:- Click on Ctrl - (macOS) the HttpExample function and choose ...
Read more >
NETSDK1045: The current .NET SDK does not support ...
Open the Solution Properties window (ctrl-click the solution in the Solution window and select Properties), select Build - General, and uncheck ...
Read more >
Azure Functions on MacOs - Visual Studio for Mac
Azure Functions is a way to create and run event-driven snippets of code –– functions –– in the cloud, without having to explicitly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found