NCrunch Forum
»
General Support
»
Build/Test Issues
»
Easy way to copy an additional file to the _ncrunchreferences folder?
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.
|
|
|
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?
|
|
|
|
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!
|
|
|
|
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.
|
|
|
|
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! :)
|
|
|
|
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.
|
|
|
NCrunch Forum
»
General Support
»
Build/Test Issues
»
Easy way to copy an additional file to the _ncrunchreferences folder?
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.NETThis page was generated in 0.041 seconds.