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?
Build/Test Issues
Can't get a required file into _ncrunchreferences
Started by CreepyGnome on 5,489 views
Remco NCrunch Developer
#8854
17 Jun 2016 23:35 UTC
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?
_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?
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.
Edited 18 Jun 2016 02:48 UTC
Remco NCrunch Developer
#8859
18 Jun 2016 03:20 UTC
CreepyGnome 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.
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.
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.
Post a reply
Log in to reply.