Build/Test Issues

Using v2.6 infered project references causes NCrunch exception

Started by johnmwright on 9,754 views

I have a large solution that uses many dll-based (not project-based) assembly references. I excitedly grabbed the new v2.6 build this morning in order to try out the inferred project references support. Unfortunately, when I enable this on my solution (change the "Infer project references using assembly names" to True), I get internal exceptions from NCrunch in several projects (both tests and non-test assemblies):


[08:26:32.8991-LocalBuildTask-4] ERROR (Internal): System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
at nCrunch.Core.BuildManagement.BuildEnvironment.Build(SnapshotComponent snapshotComponentToBuild, IList`1 referencedComponents, GridClientId gridClientId, CustomEnvironmentVariable[] customEnvironmentVariables)
at nCrunch.Core.Processing.BuildTaskLogic.DoProcessTaskAndReturnSuccessFlag()
at nCrunch.Core.Processing.TaskLogic.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.LocalProcessingTask.ProcessTaskAndReturnSuccessFlag()
at nCrunch.Client.Processing.ProcessingQueue.#=qtgmBBzjvQuenvycAjq6EQA==(LocalProcessingTask #=qJXDGE9CULxgcfKpGkTRyMA==)


Note that the same assembly that had the above exception message in the Processing Queue shows this warning message in the Tests windows (as expected):

It has been detected that this component is referencing assemblies within the build output directories of projects within this solution. It is strongly recommended that assemblies are referenced from a directory location that is not subject to disruption from the build process.

Directly referencing assemblies that are updated, copied or manipulated by the build of projects in this solution will create implicit build dependencies that cannot be tracked by NCrunch or MSBuild. This can result in inconsistent build behaviour patterns and code versioning issues. It can also cause problems when trying to execute a clean build of the solution after it is checked out of a source control system.

The following assembly references have triggered this warning:
C:\Work\XXX\Branches\MyProject\bin\YYY.Common.dll
C:\Work\XXX\Branches\MyProject\bin\YYY.Common.pdb


I currently have four instances of projects with the "An item with the same key has already been added" error. I many more instances of the "Assemblies are being referenced from the build output directories" warnings, so it doesn't appear to be a 1-1 match between the two.
Hi John,

Thanks for sharing this issue. It looks to me like you may have a project in your solution that has a project reference to another project in your solution, then an assembly reference to an assembly with the same name as this project.

.. Or something structurally similar to this. Basically the use of the infer assembly references setting has caused NCrunch to double-resolve a particular reference.

Would you mind submitting a bug report after NCrunch has finished loading the projects in your solution? The log should be able to help me identify exactly which wires have been crossed.
Bug report submitted with the same title as this post.
Thanks!

Because of a serious localisation issue in the 2.6 build, I'm rushing 2.7 out the door ..

And I've attempted to include a fix for this problem in the 2.7 build.

Could you confirm whether it does the trick for you? If so, I'll push it up to the download page:

http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.7.0.2.msi
http://downloads.ncrunch.net/NCrunch_GridNodeServer_2.7.0.2.zip
http://downloads.ncrunch.net/NCrunch_VS2008_2.7.0.2.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.7.0.2.msi
http://downloads.ncrunch.net/NCrunch_VS2010_2.7.0.2.zip
http://downloads.ncrunch.net/NCrunch_VS2012_2.7.0.2.msi
http://downloads.ncrunch.net/NCrunch_VS2012_2.7.0.2.zip
http://downloads.ncrunch.net/NCrunch_VS2013_2.7.0.2.msi
http://downloads.ncrunch.net/NCrunch_VS2013_2.7.0.2.zip
Excellent! The issue is no longer present in the 2.7.0.2 build.

I love this feature. This has been holding back several people where I work who really want to use NCrunch, so I'm excited to get them on this version! Thank you very much for adding this feature and for turning around a fix so fast!
Great stuff! Thanks for confirming the fix! I'll go ahead and release 2.7 then :)

Post a reply

Log in to reply.