Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

.net 8 Intermittent build issues (System.ArgumentException: An item with the same key has already)
npateman
#1 Posted : Wednesday, August 20, 2025 9:23:44 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/1/2022(UTC)
Posts: 8
Location: United Kingdom

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi there,

My unit test project is intermittently failing to build by NCrunch with the following error,

C:\Program Files\dotnet\sdk\8.0.413\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets: The "GenerateDepsFile" task failed unexpectedly.
System.ArgumentException: An item with the same key has already been added. Key: clypse.core.UnitTests
at System.Collections.Generic.CollectionExtensions.LibraryCollectionToDictionary[T](IReadOnlyList`1 collection)
at Microsoft.Extensions.DependencyModel.DependencyContextWriter.WritePortableTarget(String key, IReadOnlyList`1 runtimeLibraries, IReadOnlyList`1 compilationLibraries, Utf8JsonWriter jsonWriter)
at Microsoft.Extensions.DependencyModel.DependencyContextWriter.WriteTargets(DependencyContext context, Utf8JsonWriter jsonWriter)
at Microsoft.Extensions.DependencyModel.DependencyContextWriter.Write(DependencyContext context, Stream stream)
at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath)
at Microsoft.NET.Build.Tasks.TaskBase.Execute()
at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

I can fix it temporarily by closing visual studio. deleting obj and bin folders, then loading up again. But then a few changes later it's back again.

My version isn't the latest (5.11.0.1). I looked through the forum and found some old mentions about it but nothing new (unless I completely missed it)

Is this something that is addressed with a newer release or is there some kind of workaround?

Btw my solution consists of 2 projects,

clypse.core
clypse.core.UnitTests

Nick.
Remco
#2 Posted : Wednesday, August 20, 2025 10:00:26 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,349

Thanks: 994 times
Was thanked: 1337 time(s) in 1240 post(s)
Hi Nick,

Thanks for sharing this issue. This looks to be a downstream symptom of a project referencing issue, and it feels familiar to me. I remember having fixed something like it in a recent build.

I'd like to confirm whether this is a new issue. I've added a short trial license to your account on this website that you can use to unlock access to the latest version of NCrunch temporarily. Would you mind giving it a try to see if it resolves the issue?

npateman
#3 Posted : Wednesday, August 20, 2025 10:10:26 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/1/2022(UTC)
Posts: 8
Location: United Kingdom

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi there,

Not entirely sure if it's new tbh, I've not done any personal .net 8 projects for a while. It's not something I've noticed at work that's for sure, so could well be something funky with my project.

It's pretty vanilla, .net 8 class library and xunit test project.

Sure I'll give the new one a try and see how it goes...

Nick.
npateman
#4 Posted : Wednesday, August 20, 2025 10:37:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/1/2022(UTC)
Posts: 8
Location: United Kingdom

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
I just made a whole bunch of changes and the tests continued to work as expected, so looks like it's my dated build.

Thanks for confirming that, I will upgrade to get the latest version.

Nick.
1 user thanked npateman for this useful post.
Remco on 8/20/2025(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.031 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download