We have an Azure function app. Runtime version is 2. Occasionally this command fails on our build server (Jenkins running on Windows Server):
dotnet publish C:\temp\OurFunctionApp.csproj -c Release -o C:\temp\output
The error:
C:\Users\user1.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(20,5): error : Metadata generation failed. [C:\temp\OurFunctionApp.csproj]
When I run this command from command line it always works fine.
We don't have Visual Studio installed on our build server.
How to diagnose and fix this error?
.csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.8.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Project1\Project1.csproj" />
<ProjectReference Include="..\Project2\Project2.csproj" />
<ProjectReference Include="..\Project3\Project3.csproj" />
<ProjectReference Include="..\Project4\Project4.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ourlist.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
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.nuget C:\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)
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