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

Notification

Icon
Error

Can't get a required file into _ncrunchreferences
CreepyGnome
#1 Posted : Friday, June 17, 2016 11:20:27 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/21/2012(UTC)
Posts: 22
Location: Arizona

Thanks: 2 times
Was thanked: 5 time(s) in 5 post(s)
I have a shared XML file that is linked into a class library project. That file property for "Copy to Output Directory" is set to copy always. Yet for some reason it never ends up in the _ncrunchreferences folder where apparently it needs to be as the exceptions when the test run are that it cannot be found their.

I also tried linking it to the project where the tests are and making it copy always as well, and doesn't get the file to _ncrunchreferences.

So I tried using the test projects "Additional files to include" and it doesn't get the file to the _ncrunchreferences folder either.

When I use the native test runner or Resharper it has no problem running the tests.

How do you get files that are already marked to be copied to the output folder by visual studio properties to actually get to the _ncrunchreferences where it needs to be so that the tests being run can find it?
Remco
#2 Posted : Friday, June 17, 2016 11:35:28 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

_ncrunchreferences is an artificial directory created by NCrunch for the sole purpose of housing static reference assemblies that are needed to build a user project. This directory isn't used for assemblies created from your projects or for storing copied resource files. Copied resources should always be placed in the build output directory in the workspace (in the same manner as when your project is built by VS). When the 'Copy referenced assemblies to workspace' setting is enabled, NCrunch will copy resource files from referenced projects into the build output directory alongside their related assemblies.

How is your code attempting to find these files? Is it trying to use the file location of one of your static references?
CreepyGnome
#3 Posted : Saturday, June 18, 2016 2:48:07 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/21/2012(UTC)
Posts: 22
Location: Arizona

Thanks: 2 times
Was thanked: 5 time(s) in 5 post(s)
Well its not my code, but a private API written by another group in the company. The XML file is required to be in the same directory as the executing application and the DLL that requires it. This made me think that NCrunch is launching the unit tests from _ncrunchreferences and that the only file not in that directory is this XML file. I can run some tests on money, by checking the various assembly loading methods and use them in a unit test to see what locations it thinks it is in and where it trying to load assemblies from.
Remco
#4 Posted : Saturday, June 18, 2016 3:20:55 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
CreepyGnome;8858 wrote:
Well its not my code, but a private API written by another group in the company. The XML file is required to be in the same directory as the executing application and the DLL that requires it. This made me think that NCrunch is launching the unit tests from _ncrunchreferences and that the only file not in that directory is this XML file. I can run some tests on money, by checking the various assembly loading methods and use them in a unit test to see what locations it thinks it is in and where it trying to load assemblies from.


This makes sense. If the DLL is attempting to load its resources from its own directory, then it will be trying to load from _ncrunchreferences instead of the build output directory of your project.

Turning on the 'Copy referenced assemblies to workspace' setting will likely solve this problem, as the DLL will then be copied into the build output directory and will be loaded from there (where the resource file will be adjacent). However, there will be a significant performance penalty for this. If there is a way you can copy the resource file into _ncrunchreferences as a post build step or inside your test code itself, this might be better. If there is a way you can convince the other team to introduce a fallback in the resource file search logic (checking the current directory or the application domain base directory), this would create the best result.
CreepyGnome
#5 Posted : Saturday, June 18, 2016 4:28:08 PM(UTC)
Rank: Member

Groups: Registered
Joined: 8/21/2012(UTC)
Posts: 22
Location: Arizona

Thanks: 2 times
Was thanked: 5 time(s) in 5 post(s)
Yeah I tried the Copy referenced assemblies to workspace setting before for the test project and it didn't work, so I tried again and this time I only turned it on for the project that the test project references and now it worked. This feels odd that it only worked when I turned it on for the non-test library and that this feature is even there.

It seems that coping referenced assemblies and their dependent resources is a requirement for things I would think. But I am sure there are good reasons why NCrunch has this setting and requires it in this instance.

Thanks for helping resolve the issue.
1 user thanked CreepyGnome for this useful post.
Remco on 6/18/2016(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.036 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download