dotnet publish fails with 'Metadata generation failed' sometimes
I have the same issue with Net Framework 4.7.
To solve the problem you should update Microsoft.NET.Sdk.Functions
nuget package.
In order to avoid the same issue, i have created a Windows accounts (Admin) by DevOps Agent.
The goal of that is to have for each account it's own folder for nugets. (No more // issues on the same folder)C:\Users\Agent1.nugetC:\Users\Agent2.nuget...
Since i have change all Windows service with the new windows account i have no more errors in my builds ;) (need to restart the Agent Windows Service)
After sometime I just deleted and recreate the application. That worked to me