Getting NCRUNCH to honor Output Path from Project Settings?

828 views Asked by At

I have downloaded a trial version of NCrunch for Visual Studio 2013 and am trying to get it working with my solution that builds fine and has working MS Unit Tests. I am able to get NCrunch to build all the projects (a mixture of C# and C++) but every single test fails with the following message:

Assembly initialize/cleanup failed: System.TypeInitializationException: The type initializer for 'IDC_UnitTests.DataCollectorTests' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'IDC.dll' or one of its dependencies. The specified module could not be found. at IDC_UnitTests.DataCollectorTests..cctor()

Every single one of the projects has its output path defined as: ..\Debug\

It sure looks like NCrunch is not using this output path because 1. It's the same error I've seen before when I accidentally didn't set the output path of one of the project to ..\Debug 2. When I look at the NCrunch directories (AppData\Local\NCrunch\18552\69\Debug, I don't see all the project dlls there like I should. Not sure if NCrunch organizes stuff like MSBuild, but it seems suspicious.

Any ideas?

Thanks, Dave

1

There are 1 answers

0
Jeff On

NCrunch creates a separate "workspace" for each referenced DLL. For example, if you have AssemblyA.Tests.dll referencing AssemblyA.dll, NCrunch will create 2 workspaces (under AppData\Local\NCrunch\ as you've found out) in 2 separate directories, and will be able to resolve the dependencies even if the DLLs are not in the same directory.

From the docs: "Under a normal VS build, these resource files will be co-located with the output assemblies of referencing projects. Under NCrunch, this is not always the case." Read more.

However, if you're loading an assembly dynamically (i.e. Assembly.Load()), by default the runtime expects the DLL to sit next to the executing assembly, but it won't be there. In such cases you need to instruct NCrunch to bring along the dependencies using the option Copy referenced assemblies to workspace, which you can access from the NCrunch view by right-clicking the target assembly and selecting Configure selected component.

enter image description here