Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.93k stars 441 forks source link

dotnet publish fails with 'Metadata generation failed' sometimes #4055

Closed chuchuva closed 5 years ago

chuchuva commented 5 years ago

Repro steps

Provide the steps required to reproduce the problem:

dotnet publish C:\temp\OurFunctionApp.csproj -c Release -o C:\temp\output

Expected behavior

It should build without an error.

Actual behavior

OurFunctionApp -> C:\temp\bin\Release\netcoreapp2.1\bin\OurFunctionApp.dll
C:\Users\build-admin\.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]

Output of dotnet --version: 2.1.503

This error occurs sporadically on our Jenkins server. I can't reproduce it on my computer. Also, I cannot reproduce it if run this command on the Jenkins server from command line prompt.

Can you help?

ishepherd commented 5 years ago

@paulbatum or colleagues - How should we investigate this error?

ishepherd commented 5 years ago

Also asked in Stack Overflow: https://stackoverflow.com/questions/54660616/dotnet-publish-fails-with-metadata-generation-failed-sometimes

paulbatum commented 5 years ago

Maybe if you amend your command to include verbose output, there will be a clue of what the error is? See the -v option documented here.

ishepherd commented 5 years ago

Hi @paulbatum - It came back today and I captured logs with -v diag I get 50 MB of junk but it doesn't look like any of it is coming from the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll.

I notice that most of the extensions.json files do not get created - That's an expected output of this task, I think?


Anonymized snippet - Let me know if you want the whole thing privately

04:53:18.465   1:7>Target "_GenerateFunctionsExtensionsMetadataPostBuild: (TargetId:501)" in file "C:\Users\build-admin\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets" from project "<FULL-CSPROJ-PATH>" (target "_PublishBuildAlternative" depends on it):
                   Using "GenerateFunctionsExtensionsMetadata" task from assembly "C:\Users\build-admin\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\..\tools\netstandard2.0\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.dll".
                   Task "GenerateFunctionsExtensionsMetadata" (TaskId:285)
                     Task Parameter:SourcePath=<PROJECT-ROOT-DIR>\bin\Release\netcoreapp2.1\bin (TaskId:285)
                     Task Parameter:OutputPath=<PROJECT-ROOT-DIR>\bin\Release\netcoreapp2.1\bin (TaskId:285)
04:53:18.506   1:7>C:\Users\build-admin\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.0.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(20,5): error : Metadata generation failed. [<FULL-CSPROJ-PATH>]
                   Done executing task "GenerateFunctionsExtensionsMetadata" -- FAILED. (TaskId:285)
04:53:18.506   1:7>Done building target "_GenerateFunctionsExtensionsMetadataPostBuild" in project "<CSPROJ-NAME>" -- FAILED.: (TargetId:501)
04:53:18.506   1:7>Done Building Project "<FULL-CSPROJ-PATH>" (Publish target(s)) -- FAILED.
jonathanantoine commented 5 years ago

Same for me I have 3 agents on the same Virtual Machine and sometimes one of them produces this kind of error.

brettsam commented 5 years ago

@ishepherd -- could you try again with our latest sdk package? https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.26. Do you get the same thing?

paulbatum commented 5 years ago

@jonathanantoine please let us know if you still see this with version 1.0.26 that Brett mentioned above

ishepherd commented 5 years ago

@ishepherd -- could you try again with our latest sdk package? https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.26. Do you get the same thing?

Hi @brettsam @paulbatum, we upgraded a week ago and fine all week - but just now the problem reoccurred and all our builds are broken again.

The snippet I posted (https://github.com/Azure/azure-functions-host/issues/4055#issuecomment-465865509) is the same, except:

jonathanantoine commented 5 years ago

Hello,

We switched to VS hosted agent and it's working fine now. I don't know if the latest package you mention wouod have fix the issue.

waveparticlepixel commented 5 years ago

We're having the same issue on a VM with several Build Agents installed. Event with the latest version of the SDK.

HansDahle commented 5 years ago

We're also experiencing this error intermittently on a server running multiple agents. Consireded if the isse was both agents using the same nuget cache, causing some lock issue etc, but even disabling all but one agent still resultet in issues.

Workaround for us: After switching to MSBuild task instead of dotnet build, the problem seems to have gone away.

brettsam commented 5 years ago

Thanks for the reports -- we're trying to figure out where this is coming from but no one has been able to capture it for us yet.

For those reporting it: Is it reproducible once you see it? Can you hop on the agent and run your build command manually and get the same error?

If so, I've got a few things that could help us narrow it down. What's ultimately happening is that our build task calls into a console application to generate the extensions.json file. It's failing, but with no output (or at least none that we've captured). If this is reproducible, you should be able to hop on and run the same command from the command prompt and see if that fails. You'll need three things:

Once you have those, you can open a command prompt and run: dotnet [path-to-console-dll] [source-path] [output-path-with-extensions.json].

I'm also trying to beef up our logging with https://github.com/Azure/azure-functions-host/pull/4314 to see if that helps us diagnose this.

brettsam commented 5 years ago

Note that I've just pushed a new version of Microsoft.NET.Sdk.Functions -- 1.0.27 -- that contains some better logging in an effort to catch the underlying error. If possible, it'd be great if anyone experiencing this could move to this version so we can get some better output (hopefully!).

ksstott commented 5 years ago

Note that I've just pushed a new version of Microsoft.NET.Sdk.Functions -- 1.0.27 -- that contains some better logging in an effort to catch the underlying error. If possible, it'd be great if anyone experiencing this could move to this version so we can get some better output (hopefully!).

I've updated my project to version 1.0.27 and I get the following error: C:\Users\user\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.0\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(33,5): error : Metadata generation failed. Exit code: '-1073741571' Output: '' Error: 'Process is terminating due to StackOverflowException.' [<csprojpath>]

Once you have those, you can open a command prompt and run: dotnet [path-to-console-dll] [source-path] [output-path-with-extensions.json].

I also tried this, and assuming I passed the correct parameters I am getting no output whatsoever

brettsam commented 5 years ago

@ksstott thank you! Does this happen every time you build, or is it sporadic?

ksstott commented 5 years ago

@ksstott thank you! Does this happen every time you build, or is it sporadic?

It is happening all the time for me running locally (running on windows) but not happening when we are building in a docker container using the microsoft/dotnet:2.2-sdk docker image

pgussow commented 5 years ago

For me this is the error it is giving: Error processing D:\projects\FunctionApp\bin\Debug\netstandard2.0\bin\Microsoft.CSharp.dll for extension metadata: FileLoadException Could not load file or assembly 'Microsoft.CSharp, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

My scenario is a bit different though: I had a (working) solution. Then I had to migrate to a different repo, so I copied the projects into a new solution. And all of a sudden the extensions.json does not get generated anymore. On file level (within the solution) the files are equal. So I have no idea where this is coming from. The only difference I see is that they both use a different global Nuget cache folder...

brettsam commented 5 years ago

@ksstott -- I'm going to try to think through if there's any diagnostics we can try to gather that would help us narrow this down while you've got a busted setup.

@pgussow -- do you see any error messages in your build that starts with "Metadata generation failed"?

pgussow commented 5 years ago

Unfortunately no. It was not generating any extensions.json file anymore. So based on other Google-results I added the package Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator explicitly to my FunctionApp project.

I'm expecting 2 extensions there:

Maybe this gives a bit of a clue. Based on the ouytput might it be the sequencing of the targets? As the metadata is called before the function.json is generated?

build_output.txt

pgussow commented 5 years ago

I also tried with using the 1.1.0 version of the ExtensionsMetadataGenerator. No luck unfortunately

build_output_1.1.0.txt

As you can see in the output the Microsoft.CSharp-error is gone. What I did was create a new project from scratch using the VS2017 wizard. Then I copied in the old function codes and fixed the dependencies via Nuget installs.

Unfortunately the extensions.json is still empty :(

brettsam commented 5 years ago

@ksstott -- assuming you can continue to reproduce this locally. If you run your build command with detailed verbosity (like with dotnet publish /v:d), you should get a log that includes some details about the paths that we're running the extension metadata generator against and the parameters we're passing in. You can search for Task "GenerateFunctionsExtensionsMetadata" to see where those sections start. If there's multiple projects, it should be clear which one has failed.

In that section you should see something like:

Task "GenerateFunctionsExtensionsMetadata"
  Extensions generator working directory: 'C:\Users\brettsam\.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.0\build\..\tools\netstandard2.0\..\netstandard2.0\generator'
  Extensions generator path: 'C:\Program Files\dotnet\dotnet.exe'
  Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.Console.dll "E:\projects\FunctionApp55\bin\Debug\netcoreapp2.1\bin" "E:\projects\FunctionApp55\bin\Debug\netcoreapp2.1\bin\extensions.json"
Done executing task "GenerateFunctionsExtensionsMetadata".

Those three lines inside the Task log show what we're doing -- the first line is the working directory and combining the second and third lines show what command we're running. For my example that would be C:\Program Files\dotnet\dotnet.exe Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.Console.dll "E:\projects\FunctionApp55\bin\Debug\netcoreapp2.1\bin" "E:\projects\FunctionApp55\bin\Debug\netcoreapp2.1\bin\extensions.json".

So, first -- if you open a command prompt, navigate to the working directory and execute the command, do you see the same error?

If so, I've shared an updated console app that does some more logging here: https://github.com/brettsam/file-share/archive/master.zip. If you can unzip that, navigate to it, and run the same command as you ran above, do you get any new output?

If so, would you share it? It's just an output of file load events, but if you would rather send it to me directly via email, that works too. My email is in my profile.

pgussow commented 5 years ago

Based on your reply I think I figured it out what is going wrong: When I ran the command which my logging states: Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.Console.dll "D:\projects\SomeComp.IntegratieEnOntwikkeling\Azure\FunctionApps\Integrationhub\SomeComp.IntegrationHub2\bin\Debug\netcoreapp2.1" "D:\projects\SomeComp.IntegratieEnOntwikkeling\Azure\FunctionApps\Integrationhub\SomeComp.IntegrationHub2\bin\Debug\netcoreapp2.1\extensions.json"

again an empty extensions.json. But now I added the \bin to my source and then it does get generated.

Then looking at the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets file I guess the problem is that the _IsFunctionsSdkBuild is not true and thus the _FunctionsTaskFramework is not filled properly. But this is filled from the functions SDK.

So I guess I need to figure out the way to force VS2017 Build to use the Core version instead of the Full version

brettsam commented 5 years ago

@pgussow -- what does your project file look like? Sounds like it's different than the StackOverflow that we're occasionally seeing, so I may split it out into a separate issue if it looks unrelated to this specifically...

fabiocav commented 5 years ago

Investigation is in progress. Updates were made and we're getting additional information, but this will go into next sprint.

pgussow commented 5 years ago

To summarize my findings:

  1. When using Microsoft.NET.Sdk.Functions 1.0.27 I get the Microsoft.CSharp 4.0.4.0 exception.
  2. When using Microsoft.NET.Sdk.Functions 1.0.24 I DO NOT get the Microsoft.CSharp 4.0.4.0 exception.
  3. After adding these lines to my project file the extension generation works: <_FunctionsTaskFramework>netcoreapp2.1

So my conclusion is that for some reason the _FunctionsTaskFramework does not get filled. And that is causing the ExtensionMetadataGenerator to look into the wrong folder for the assemblies to parse. Because if I manually run the tool and add the \bin to the command then the extensions.json gets generated properly.

Would it be usefull to attach the complete build output for analysis? FunctionApp.zip

brettsam commented 5 years ago

I believe I've got a fix for the StackOverflow exception: #4382.

If anyone wants to try this before the release by manually copying over the Console.dll file to your path at {localnugetcache}\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.0\tools\netstandard2.0\generator, you can give that a try. I'm going to try to push to get an updated Microsoft.NET.Sdk.Functions release out soon to see if it solves all the problems or if there are more lurking behind this.

brettsam commented 5 years ago

@pgussow -- I've forked a new issue here for us to dig into what you're seeing: https://github.com/Azure/azure-functions-host/issues/4383

pksorensen commented 5 years ago

@brettsam

I copied over the new dll and could move past a problem:

here is the output (assuming thats fine, no functions stuff should be in the view dll): 1>C:\Users\pksor.nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.0\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(20,5): warning : Could not evaluate 'IO-Board.Portal.Views.dll' for extension metadata. If this assembly contains a Functions extension, ensure that all dependent assemblies exist in 'C:\dev\io-board\io-board\functions\IO-Board.Portal.FunctionHost\bin\Debug\netcoreapp2.2\bin'. If this assembly does not contain any Functions extensions, this message can be ignored. Exception message: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.RazorPages, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

pksorensen commented 5 years ago

In my case, I was working on razor pages and had to include these two packages to my function project also (when referencing an aspnet core project from the function project).

    <PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" />
thecontrarycat commented 5 years ago

@brettsam That updated console.dll you linked made the difference for me. For reference, I was using the Jil serialiser in an assembly referenced by my functions project, and it in turn references Sigil which is a netstandard1.5 assembly that does all sorts of fun Reflection.Emit things.

The message I get now is this:

Could not evaluate 'Sigil.dll' for extension metadata. 
If this assembly contains a Functions extension, ensure that all dependent assemblies exist in 
    '<snipped>\bin\Debug\netcoreapp2.1\bin'. 
If this assembly does not contain any Functions extensions, this message can be ignored. 
Exception message: 
    Could not load file or assembly 'System.Runtime.InteropServices.PInvoke, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
The system cannot find the file specified.
brettsam commented 5 years ago

Thanks for the confirmation @thecontrarycat! Did you see that message as a build warning? I've changed it to be a Message (rather than Warning) so that you shouldn't get constant warnings about an assembly that likely won't have any Functions extensiosn in it.

brettsam commented 5 years ago

https://www.nuget.org/packages/Microsoft.NET.Sdk.Functions/1.0.28 has been released, which contains this fix. Please give it a try and let me know if you continue to have issues with your builds.

Huge thanks to everyone that helped us debug this. The latest release has more diagnostic logging so it may be easier to detect these kinds of things in the future.

thierry-prost commented 5 years ago

The 1.0.28 update has broken my build with a new 'Metadata generation failed' (when running both locally and in VSTS). I simply reverted from 1.0.* to 1.0.27 because the older package still works fine.

However, I thought the bug report might be relevent here. The fix might be easy as you'll notice the "binbin" extension and I suspect it has to do with the "_FunctionsExtensionsTasksDir", but this is where my expertise ends.

Thanks for the great SDK


[...].nuget\packages\microsoft.azure.webjobs.script.extensionsmetadatagenerator\1.1.1\build\Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets(33,5): error : Metadata generation failed. Exit code: '-532462766' Error: 'Error generating extension metadata: System.IO.DirectoryNotFoundException: The path '[...]\bin\Debug\netcoreapp2.1\binbin' does not exist. Unable to generate Azure Functions extensions metadata file.   at ExtensionsMetadataGenerator.ExtensionsMetadataGenerator.Generate(String sourcePath, String outputPath, ConsoleLogger logger) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\ExtensionsMetadataGenerator.cs:line 23   at ExtensionsMetadataGenerator.Console.Program.Main(String[] args) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\Program.cs:line 32Unhandled Exception: System.IO.DirectoryNotFoundException: The path '[...]\bin\Debug\netcoreapp2.1\binbin' does not exist. Unable to generate Azure Functions extensions metadata file.   at ExtensionsMetadataGenerator.ExtensionsMetadataGenerator.Generate(String sourcePath, String outputPath, ConsoleLogger logger) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\ExtensionsMetadataGenerator.cs:line 23   at ExtensionsMetadataGenerator.Console.Program.Main(String[] args) in C:\azure-webjobs-sdk-script\tools\ExtensionsMetadataGenerator\src\ExtensionsMetadataGenerator.Console\Program.cs:line 37```
brettsam commented 5 years ago

Thanks for the report @QuantechTP! Is there any chance that you could kick off a build with "/bl" as your command line and email me the msbuild.binlog file that it generates? My microsoft email is in my github profile.

pksorensen commented 5 years ago

Is there a solution to the following problem: https://twitter.com/pksorensen/status/1131080645696983040

How do i get to build when one of my other dependencies need json >=12.0.2?

3>DotNETDevOps.FrontDoor.RouterFunction -> C:\dev\DotNETDevOps.FrontDoor\functions\DotNETDevOps.FrontDoor.RouterFunction\bin\Debug\netcoreapp2.2\bin\DotNETDevOps.FrontDoor.RouterFunction.dll
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'.
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Runtime.Loader.AssemblyLoadContext.LoadFromPath(IntPtr ptrNativeAssemblyLoadContext, String ilPath, String niPath, ObjectHandleOnStack retAssembly)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.Assembly.LoadFrom(String assemblyFile)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.Assembly.LoadFromResolveHandler(Object sender, ResolveEventArgs args)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.AppDomain.InvokeResolveEvent(ResolveEventHandler eventHandler, RuntimeAssembly assembly, String name)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at System.Reflection.RuntimeAssembly.GetExportedTypes()
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :    at MakeFunctionJson.FunctionJsonConverter.TryRun()
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : 
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : 
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Error generating functions metadata
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error :
3>C:\Users\pksor\.nuget\packages\microsoft.net.sdk.functions\1.0.28\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets(41,5): error : Metadata generation failed.
3>Done building project "DotNETDevOps.FrontDoor.RouterFunction.csproj" -- FAILED.
mioconnor commented 5 years ago

@QuantechTP @brettsam Did you manage to get to the bottom of the /binbin path issue?

brettsam commented 5 years ago

I can't remember -- there's been a bunch of fixes here :-)

If you're seeing a problem with Microsoft.Net.Sdk.functions 1.0.29, can you open a new issue with the description and I can take it from there? Feel free to mention me (and link it in a comment here) and I can take a look. If you're able to run the build with "/bl" and email me (email is in my github profile) the msbuild.binlog file that it generates, that has been a huge help in investigating these.

drlawler commented 5 years ago

I was able to get past the "binbin" issue by editing the Directory.Build.targets file in the function project.

I changed the line

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)bin

to remove the "bin"

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)</_FunctionsExtensionsDir>

it looks like the $(TargetDir) variable already includes the "bin", so having it here also doubles it up.

This was for an existing project. When I created a new project, the entire file is not there.

So then I tried deleting the Directory.Build.targets file, and that also seemed to work.

Hope that helps somebody ;)

brettsam commented 5 years ago

We already perform that tranformation here: https://github.com/Azure/azure-functions-host/blob/f7f9d4fc8f82c5e7f87f3d4a3ccd5c18944d02b3/tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator/Targets/Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator.targets#L23

Your Directory.Build.targets file may have been there to fix some older issue and it's no longer needed (and in fact, seems like it's breaking things). Thanks for coming back to let us know!

ThatBlokeCalledJay commented 5 years ago

I was able to get past the "binbin" issue by editing the Directory.Build.targets file in the function project.

I changed the line

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)bin

to remove the "bin"

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)</_FunctionsExtensionsDir>

it looks like the $(TargetDir) variable already includes the "bin", so having it here also doubles it up.

This was for an existing project. When I created a new project, the entire file is not there.

So then I tried deleting the Directory.Build.targets file, and that also seemed to work.

Hope that helps somebody ;)

This worked for me (1.0.29)

25308985 commented 5 years ago

Upgrade your Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator to 1.1.2 will solve the issue

pcocko commented 5 years ago

I've upgraded Microsoft.NET.Sdk.Functions to last version (1.0.29) and it solved my problem. It also includes Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator 1.1.2 version.

zuckerthoben commented 5 years ago

I have updated to 1.0.29 but ran in this issue again today. I also have the issue that sometimes the zip / web deploy options are missing when I click on "publish" in the right-click menu of the Azure Function in VS 2019 (16.3.3)

didaskein commented 5 years ago

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)

didaskein commented 5 years ago

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)

gilmishal commented 4 years ago

tried upgrading my functions to v3 with Microsoft.NET.Sdk.Functions 1.30.0-beta2 and I get the "binbin" problem, it uses Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator 1.1.2.

gilmishal commented 4 years ago

I was able to get past the "binbin" issue by editing the Directory.Build.targets file in the function project.

I changed the line

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)bin

to remove the "bin"

<_FunctionsExtensionsDir Condition="$(_IsFunctionsSdkBuild) == 'true'">$(_FunctionsExtensionsDir)</_FunctionsExtensionsDir>

it looks like the $(TargetDir) variable already includes the "bin", so having it here also doubles it up.

This was for an existing project. When I created a new project, the entire file is not there.

So then I tried deleting the Directory.Build.targets file, and that also seemed to work.

Hope that helps somebody ;)

This worked for me (1.30.0-beta2)

brettsam commented 4 years ago

I think the usage of Directory.Build.targets was for an old bug. Some people still have that file floating around, but it shouldn't be needed anymore and ends up applying "bin" twice.