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

Notification

Icon
Error

Easy way to copy an additional file to the _ncrunchreferences folder?
mortan
#1 Posted : Thursday, March 26, 2015 3:24:53 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/26/2015(UTC)
Posts: 6

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi!

My projects are referencing a nuget package that contains an assembly and a configuration file. On build both files are copied to the bin\Debug\ folder and everything works (assembly is loading the configuration file relative to its file path). Using ncrunch the referenced assembly is placed in the _ncrunchreferences folder but not so the configuration file.

I figured out that setting "Copy referenced assemblies to workspace" works (config file gets copied to the same place as the assembly) but makes the bin\Debug folder inside my ncrunch workspace explode. I tried the "Include additional files" setting, but the config file ends up in the wrong place (not in the _ncrunchreferences folder).

I'm wondering if there is an easy way to copy the config file to the right place without enabling "Copy referenced assemblies to workspace"...


Help appreciated! :)

Kind regards!
1 user thanked mortan for this useful post.
mc-clasoft on 9/17/2018(UTC)
Remco
#2 Posted : Thursday, March 26, 2015 10:30:36 PM(UTC)
Rank: NCrunch Developer

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

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

Unfortunately the 'Copy referenced assemblies to workspace' setting is intended to be the solution to this problem. The setting can't differentiate between the file you need and the files you don't, so it just copies them all as per normal build behaviour.

What sort of config file is being copied? Is it perhaps possible to have some code running at the beginning of every test (or as a SetUpFixture) that can copy the file into the expected place as a workaround?
mortan
#3 Posted : Friday, March 27, 2015 9:03:59 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/26/2015(UTC)
Posts: 6

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Hi Remco!

Copying the file to the ncrunchreferences directory in a SetUpFixture method could work, but it's not something I would like to do (hard wire the unit tests to ncrunch feels very wrong to me).

I was searching for an option to specify the output folder in the "Include additional files"... unfortunately there is none. :( That would be the most appropriate solution in my opinion. I mean "Copy referenced assemblies to workspace" works... it just slows down the process a bit and I think that including a nuget package that consists of a dll and a configuration file for this dll is not *that* uncommon!

Regards!
Remco
#4 Posted : Friday, March 27, 2015 11:09:39 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Sorry :( I've suggested the only options that I know will solve this problem. There isn't an in-between in terms of the Copy referenced assemblies behaviour - this is all controlled by MSBuild rather than NCrunch. When the setting is disabled, NCrunch just suppresses the entire set of behaviour.

You could always use '#if NCRUNCH' if you want to implement a workaround and avoid running the code for non-NCrunch runners.
mortan
#5 Posted : Friday, March 27, 2015 12:04:06 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/26/2015(UTC)
Posts: 6

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Ah I see. Well if it is a limitation coming from MSBuild I will stick with the "Copy referenced assemblies to workspace" option.

Maybe you got an idea for this issue of mine?

Thanks for your help! :)
TURNSKIN
#6 Posted : Thursday, December 31, 2015 8:43:35 AM(UTC)
Rank: Member

Groups: Registered
Joined: 8/31/2015(UTC)
Posts: 18
Location: Lithuania

Thanks: 6 times
Was thanked: 2 time(s) in 2 post(s)
Hi,
Here is code to copy file from bin to _ncrunchreferences.
I had problems running EVO HTML to PDF Converter for .NET with error:
Quote:
System.Exception: Could not start conversion. WinApi error code 2. Check 'evointernal.dat' file has execute permissions and that it exists near evohtmltopdf.dll or set the EvoInternalFileName property with the full path of the file


Code:
static void SetupNCrunch()
{
#if NCRUNCH
var pathTo = NCrunch.Framework.NCrunchEnvironment.GetAllAssemblyLocations()
.Single(x => x.EndsWith("evohtmltopdf.dll", StringComparison.InvariantCultureIgnoreCase))
.Replace("evohtmltopdf.dll", "evointernal.dat");
var pathFrom = Path.Combine(Path.GetDirectoryName(NCrunch.Framework.NCrunchEnvironment.GetOriginalProjectPath()), @"bin\Debug\evointernal.dat");

if (!File.Exists(pathTo))
File.Copy(pathFrom, pathTo);

//nuget Install-Package FluentAssertions
pathFrom.Should().Be(@"C:\VSC\project\src\AcceptanceTests\bin\Debug\evointernal.dat");
File.Exists(pathFrom).Should().BeTrue();

pathTo.Should()
.StartWith(@"C:\Users\name\AppData\Local\NCrunch\")
.And.EndWith(@"\_ncrunchreferences\evointernal.dat");
File.Exists(pathTo).Should().BeTrue();
#endif
}
1 user thanked TURNSKIN for this useful post.
Remco on 12/31/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.041 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download