Build/Test Issues

NCrunch fails to build project using MS Fakes

Started by ccampbell on 8,370 views

I have a unit test project using MSTest & MSFakes that tests a WPF executable. When it builds in NCrunch, it gets the following error:
NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
NCrunch experienced an unexpected error while trying to process results from this build: System.Exception: Unable to retrieve property values from expression in build output: $(OutDir)$(TargetName)$(TargetExt)
at #=qgE8L71ASAmrVSfk0M4L274KPWxFGEyZQbEInGFpOIrJqMVtSOvWyb6UnlH84MYYykFL1G3geW9U2Zx5xcKxS5A==.#=qvngGfryJD6MRhhWCVr49e4ta3ETSokp$f17JyMhtuO8=(IList`1 #=qkCjHpk7_b8BDIasDGVQzRw==)
at #=qs1HLkIL_Tfslg21bawCHvnz7YwVTrgaBiAVxRe7bMJnS8kVpKc10rh6$3LI$UzvvEGk0sEaolOBTt42ujDcUvA==.#=q4KH$p4ixtdBrFcc94fR1mpVfDUP7Zk1fy3FzGExkG$w=.#=qC8D43rxc8TETeyYisRiavWdevqWrmEx2aBCiqD6Vq6iiwfY1HAJt0ZB9xsbj56uC(#=qYOYBFdVAQ1_c9d8HU8qBCXx8p9WK4ClDqnlyCXciRWOHh5yCxGIKnIuE8PihCGl7RjV$5l59yOBt99Tx$0kHjw== #=qHZB7JZq4zxfePe1Xd5FBEw==)
at nCrunch.Common.ListExtensions.Do[T](IEnumerable`1 list, Action`1 action)
at #=qs1HLkIL_Tfslg21bawCHvnz7YwVTrgaBiAVxRe7bMJnS8kVpKc10rh6$3LI$UzvvEGk0sEaolOBTt42ujDcUvA==.#=q0hlM6jfBnZ3llhGgwysyeRKlSMy4gHm_Y4uSRcwcGbkBb$QjfwxS70Z_67cPEtme(IList`1 #=q_7HVbczhh6lv5JvQvyQEow==)
at #=q3NM6XOlvCIh4Gm09$CRDNxM_kpy6WD0$43gFGGOnn1V0ya94LWAEWXKJshy9IB$9.#=q_d6o60$oQBj$AMUsM27g2O1k4CoMCcOuIilGTa$Tf3dzRxVbiOjCyqO$G5Csekcm(IList`1 #=qABDi6JLZ05AZhRiTpA0SuA==)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)

I am using NCrunch 2.5.0.12 and Visual Studio 2012 Update 4. I've tried everything in the linked article. What can I do to figure out why this is failing?
Hi,

Thanks for sharing this issue.

This is a blanket exception thrown by NCrunch whenever it executes a build that fails to complete, but provides no error information.

The first step in to trying to resolve this would be to get a detailed log from the build. Set the log verbosity configuration setting to 'Detailed', then try rebuilding the project using NCrunch (hit the reset button if you need to). If you open up the Processing Queue then select the failed build task, you should find a detailed dump of the build output in the text pane below. Does this text dump give any useful information that catches your eye?
Ok, I changed the logging verbosity and read through the logs. It looks like a problem generating Fakes:
3:start> Fakes\Client.fakes
Microsoft Fakes v11.0.60315.1 - .NET v4.0.30319
Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.

fakes
code : assembly C:\...\AppData\Local\NCrunch\19896\113\Client\bin\Client.exe failed to load properly
fakes generator 1 errors, 0 warnings
3:end> Fakes\Client.fakes error while loading the assembly (-1005 - 0xfffffc13)

The client depends on Prism & MEF, and after much experimentation I found that if I added nuget references for Prism & Prism MEF Extensions to my test project, the fakes started generating.
Is there something weird with NCrunch and Fakes/MEF?
Nice work in identifying this. I would be willing to bet that this problem is related to Fakes attempting to load the Prism/MEF assemblies during its generation of the Fakes. Because NCrunch suppresses the copying of referenced files to the build output directory of projects by default, Fakes would fail to find these assemblies then explode.

There are two ways you can solve this problem:

1. Include the Prism/MEF extensions as part of your test project (as you have done). This is the approach I would recommend as it will give the best performance.
2. Turn on the Copy referenced assemblies to workspace setting for the projects that are involved. This will tell NCrunch to always copy the referenced assemblies, thereby allowing the build to function as it would when you invoke it from your IDE. The major drawback of this approach is that you'll lose some very significant optimisations that NCrunch makes to your build, so everything will run slower.

I admit that I'm a bit disappointed in the way this error is being reported. I would have hoped that Fakes build tasks would provide errors and warnings using the standard MSBuild approach.
Thanks for your help! I just found out that you can add a "Verbosity" attribute to the root element of your fakes file to get additional error info from the MSBuild task:
<Fakes xmlns="(- BROKEN LINK -)" Diagnostic="true" Verbosity="Noisy">

If you add that and set NCrunch logging verbosity to "detailed", the log for the failed project in the processing queue will show the actual error reason.
Wow, nice find! I might see if I can rig up NCrunch to manipulate this file and show the error automatically. Thanks for letting me know about this.

Post a reply

Log in to reply.