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.

Getting "GenerateDepsFile" task failed unexpectedly with KeyNotFoundException when publishing project

See original GitHub issue

I am getting "GenerateDepsFile" task failed unexpectedly with KeyNotFoundException when publishing my projects.

Below are the conditions that trigger the issue:

  • .NET Core 3.0 Preview 4
  • WindowsAzure.Storage 9.3.3 is in a .NET Standard library

This can be fixed by either going back to Preview 3 or add WindowsAzure.Storage directly into the .NET Core project.

Error in build log:

C:\Program Files\dotnet\sdk\3.0.100-preview4-011223\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(801,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Microsoft.NET.Build.Tasks.DependencyContextBuilder2.CalculateExcludedLibraries() in /_/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder2.cs:line 769
   at Microsoft.NET.Build.Tasks.DependencyContextBuilder2.Build() in /_/src/Tasks/Microsoft.NET.Build.Tasks/DependencyContextBuilder2.cs:line 215
   at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFileNew(String depsFilePath) in /_/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs:line 248
   at Microsoft.NET.Build.Tasks.GenerateDepsFile.ExecuteCore() in /_/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs:line 284
   at Microsoft.NET.Build.Tasks.TaskBase.Execute() in /_/src/Tasks/Common/TaskBase.cs:line 35
   at Microsoft.NET.Build.Tasks.GenerateDepsFile.Execute() in /_/src/Tasks/Microsoft.NET.Build.Tasks/GenerateDepsFile.cs:line 262
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Sample repository: https://github.com/nguyenquyhy/IssueWindowsAzureStoragePublish

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
chriss2401commented, Oct 1, 2019

Can anyone help with where to put <DepsFileGenerationMode>old</DepsFileGenerationMode> ? I tried in my csproj file and it doesn’t work.

11reactions
dsplaistedcommented, Apr 24, 2019

I’m not sure if this has been fixed for preview 5 or not. I will take a look. However, you can work around the issue by setting the following MSBuild property:

<DepsFileGenerationMode>old</DepsFileGenerationMode>
Read more comments on GitHub >

github_iconTop Results From Across the Web

NET Core solution build gives a GenerateDepsFile error
The "GenerateDepsFile" task failed unexpectedly is too large and you should check its detailed build log to judge what is the real problem....
Read more >
The "GenerateDepsFile" task failed unexpectedly.
Error MSB4018 The "GenerateDepsFile" task failed unexpectedly. System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
Read more >
Error MSB4018: the “generatedepsfile” task failed ...
I recently ran into a compilation error that is preventing me from building and running my WebAPI. It was working perfectly just the...
Read more >
The "GenerateDepsFile" task failed unexpectedly. I ...
The "GenerateDepsFile" task failed unexpectedly. I downloaded the VS2022 and trying to convert the .net 4.8 framework project to .
Read more >
GenerateDepsFile task failed unexpectedly
Hello, All of a sudden, building with Travis is failing. travis.yml hasn't been modified between then and now. The error message is as ......
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