GenerateDepsFile Build Error: An item with the same key has already been added.
See original GitHub issueIssue moved from microsoft/msbuild#5509
- Please respond to @rlmartins76.
From @rlmartins76 on Sunday, July 12, 2020 9:06:17 PM
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: System.ArgumentException: An item with the same key has already been added.
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.Extensions.DependencyModel.DependencyContextWriter.WritePortableTarget(IReadOnlyList`1 runtimeLibraries, IReadOnlyList`1 compilationLibraries)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.Extensions.DependencyModel.DependencyContextWriter.WriteTargets(DependencyContext context)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.Extensions.DependencyModel.DependencyContextWriter.Write(DependencyContext context)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.Extensions.DependencyModel.DependencyContextWriter.Write(DependencyContext context, Stream stream)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateDepsFile.ExecuteCore()
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute()
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
C:\Program Files\dotnet\sdk\3.1.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
NET Core solution build gives a GenerateDepsFile error
It tries to add an item to a dictionary when it already exists, but not which dictionary it is trying or what duplicate...
Read more >compilation error MSB4018: The “GenerateDepsFile” task ...
Error MSB4018 The “GenerateDepsFile” task failed unexpectedly. System.ArgumentException: An item with the same key has already been added.
Read more >The "GenerateDepsFile" task failed unexpectedly. I ...
I Created the new console application (.NET 6) , even that is showing the same error. 0 votes
Read more >Error MSB4018: the “generatedepsfile” task failed ...
NET.Sdk\targets\Microsoft.NET.Sdk.targets(194,5): error MSB4018: System.ArgumentException: An item with the same key has already been added.
Read more >GenerateDepsFile task failed unexpectedly
All of a sudden, building with Travis is failing. travis.yml hasn't been modified between then and now. The error message is as follows:....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Figured my problem out - I’d changed the
PackageId
of a project to a name that matched the name of another project that referenced it. To be honest I didn’t expect the PackageId to have any effect when using a project reference, but you live and learn.I’ve had the same problem, but in my case I had 2 projects with the same
AssemblyName
(and different values forPackageId
).