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

Notification

Icon
Error

"Additional files to include" only relative to project file path?
Unger
#1 Posted : Thursday, March 26, 2015 11:31:25 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/19/2013(UTC)
Posts: 9
Location: Austria

Was thanked: 3 time(s) in 3 post(s)
Following situation: To optimise performance for compiling and testing, I configured VS in that way, that all binaries (obj, bin) are compiled in a RAM-Disk (including the windows-temp-folder).

But some tests require additional files, that are compiled to this RAM-Disk. Configuring NCrunch to use some of this files is not possible. The config-editor breaks when I try to add a folder from an other drive. Editing the NCrunch-config-file also has no effect. It doesn't work.

Running the tests with NUnit with the files in the RAM-Disk works without any errors.

Is there a workaround?
Remco
#2 Posted : Thursday, March 26, 2015 11:38:53 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Unfortunately there's no way the 'Additional files to include' feature can work with files on a different disk. This is because the feature itself works by copying the files to a location in the NCrunch workspace with an identical relative directory structure when compared to the foreground solution.

Relative paths to files on a different disk are impossible. This means that there's no way you could be referencing these files from your solution using a relative path. The references must be absolute. This means that using the 'Additional files to include' is probably unnecessary, as any code using the files would simply pick them up at their absolute path, ignoring anything copied into the NCrunch workspace anyway.

What kind of results do you get when you run the tests with NCrunch at the moment? Are they unable to find the files?
Unger
#3 Posted : Thursday, March 26, 2015 11:58:05 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/19/2013(UTC)
Posts: 9
Location: Austria

Was thanked: 3 time(s) in 3 post(s)
The files, which should be used, are compiled files from another project within the solution. BUT, these files are not referenced at all in the test-project-VS-file, and this should never happen!

All projects are configured to use the same solution-bin-folder (not the default project-bin-folder!) to keep all files together. In the *.??proj-Files I use

Code:
<BaseOutputPath>T:\Projects\Project\bin\</BaseOutputPath>
<BaseIntermediateOutputPath>T:\Projects\Project\obj\</BaseIntermediateOutputPath>


and

Code:
<OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath>


And in the ncrunchproject-File:

Code:
<AdditionalFilesToInclude>T:\Projects\Project\bin\Debug\TestItem.*.dll;
T:\Projects\Project\bin\Debug\TestItem.*.pdb;
T:\Projects\Project\bin\Debug\TestItem.*.exe</AdditionalFilesToInclude>


NCrunch does not copy the included files, and therefore the tests quit with error.
Remco
#4 Posted : Thursday, March 26, 2015 10:27:51 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
Thanks, I think I now have a better understanding of the problem you're trying to solve.

The 'Additional files to include' feature wasn't intended to resolve problems such as this, so I suggest steering clear of it. The problem itself is that of an 'implicit co-location dependency' on another project's output assembly. Unfortunately, this is challenging to solve in NCrunch because of the way that it needs to wire test runner application domains together arbitrarily.

You can read more about assembly co-location assumptions and why they are a problem for NCrunch.

In most cases, when I see assembly co-location assumptions such as this, they apply to projects that are actually being referenced by the test project (directly or indirectly). In your case, you have a project that is completely detached from the referencing project and I assume is being loaded dynamically somehow. The good news is that it is still possible to make this work - it's just complicated.

You'll need to tell NCrunch about the implicit dependency between these projects using the implicit project dependencies configuration setting. This will allow you to identify the referenced DLL at test runtime by making a call to NCrunchEnvironment.GetImplicitlyReferencedAssemblyLocations(). You can then choose to either:

1. Adjust your code so that the test can control where the assembly is loaded from, and inject the known path into the code (perhaps via IOC, dependency injection, etc).
... or ...
2. Adjust the test code so that it will copy the file to the same directory as your code is expecting to load it from. Note that if you are doing this, you'll need to be mindful of file locking exceptions if you are running tests in parallel.

If you still need to be able to run the tests outside of NCrunch (where the NCrunchEnvironment service calls won't work), you can enclose the NCrunch-specific code using:

#if NCRUNCH
...
#endif
Unger
#5 Posted : Friday, March 27, 2015 10:45:31 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 7/19/2013(UTC)
Posts: 9
Location: Austria

Was thanked: 3 time(s) in 3 post(s)
Thank you for your feedback!

Finally, I did it the dirty/ugly way, because the other ways you mentioned did not work in my case. Now in test-code, I reference to the absolute path of the build-binaries. I know, it's very ugly ... :-)
1 user thanked Unger for this useful post.
Remco on 3/27/2015(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.136 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download