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

Notification

Icon
Error

NCrunch Does Not Copy Files Marked "Copy Always"
Rodney
#1 Posted : Wednesday, April 22, 2015 6:10:32 PM(UTC)
Rank: Member

Groups: Registered
Joined: 12/7/2012(UTC)
Posts: 17
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I have an NUnit test project, and I have a Resources folder that has text files, and other items, several with a Copy to Output Directory setting of Copy always. However while MSBuild, R# and other test runners seem to obey this important setting, NCrunch appears to ignore it. This is the TEST project saying to copy always, not a dependent project in the same solution that the test uses or is under test but the actual test project.

If a file is flag as copy always for the Copy to Output DIrectory it should be obeyed by NCrunch. I shouldn't have to use a proprietary NCrunch function to include additional files, when the project file already has a way to include and copy files to the build output.

Is there a setting in NCrunch that allows enable it to obey this standard build functionality? I haven't found one yet, and if there is one why would it ever be disabled to not copy a file marked to be copied?
Remco
#2 Posted : Wednesday, April 22, 2015 11:07:50 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

NCrunch doesn't contain any code to deliberately disable the copying of resource files to the build output directory within a project. This logic is built into MSBuild and it isn't overridden. However, there are limitations around the copying of resources files from projects that are depended on.

The first thing I would check is that the resources files are actually being copied to the NCrunch workspace prior to the build being run. Try browsing to the workspace (right click the failed project, go to Advanced->Browse to workspace). Check through the workspace to see if the resource files are in the workspace in their source directory (i.e. not the bin\debug directory). If not, this may simply be a dependency that needs to be marked out inside the project file or using the NCrunch 'Additional files to include' setting.

The next thing I would try is running MSBuild.exe against the project file that NCrunch has created in the workspace. This allows you to simulate the build in a similar manner to NCrunch, and you can also troubleshoot accordingly by making changes to the project file to see how MSBuild will behave. Does a command-line execution of MSBuild against the project file copy the files correctly?

Finally, I would also suggest for diagnostic purposes turning on the 'Copy referenced assemblies to workspace' setting for all the projects in your solution. This may help us to understand whether there is something else being suppressed by this behaviour, or whether I have misunderstood the problem you're experiencing.
Rodney
#3 Posted : Wednesday, April 22, 2015 11:30:38 PM(UTC)
Rank: Member

Groups: Registered
Joined: 12/7/2012(UTC)
Posts: 17
Location: United States of America

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
First this has nothing to do with dependent projects or referenced assemblies. This issue is just with the files within the actual test project that are not embedded resources and have the build action on none or content, and the copy to output directory set to copy always or copy if newer.

I have confirmed that NCrunch workspace does have the files in the src folder but not in the bin\debug\* folders where they are required, this is why I am reporting the issue.

I have run this test project tests with the stand alone NUnit test runner, and the Resharper NUnit test runner and they all end up copying the files. Only NCrunch is not respecting the setting. So MSBuild is doing it job when being used by other tools, just something NCrunch is doing is preventing this from occurring.

Now while I was writing this response I deleted the files and re-added them back and now it is copying the files to the output folder, which is odd that it wasn't before when other tools where. So I still there there is an issue here however my reproducible environment just became a non-reproducible environment while I was writing this response. I was checking the things you asked and it was reproducing, I decided to delete and re-add them after verifying the things as another test and it fixed whatever was screwed with. So until I can get a standalone reproducible environment I can send you not much either of us can do on the issue until then I guess.

nCubed
#4 Posted : Sunday, February 26, 2017 5:21:00 PM(UTC)
Rank: Member

Groups: Registered
Joined: 11/1/2012(UTC)
Posts: 22
Location: United States of America

Thanks: 1 times
Was thanked: 4 time(s) in 4 post(s)
Rodney;7248 wrote:
First this has nothing to do with dependent projects or referenced assemblies. This issue is just with the files within the actual test project that are not embedded resources and have the build action on none or content, and the copy to output directory set to copy always or copy if newer.

I have confirmed that NCrunch workspace does have the files in the src folder but not in the bin\debug\* folders where they are required, this is why I am reporting the issue.


I was having the same issue with NCrunch not picking up files marked as copy always.

When MS Test / R# runs the test, both the AppDomain.CurrentDomain.BaseDirectory and Assembly.GetExecutingAssembly().Location will be the same directory.

When NCrunch runs the test, the directories are different:

Code:

AppDomain (file *does not* exist):
C:\Users\<user>\AppData\Local\NCrunch\8648\2\<project>.UnitTests\bin\Debug\<file>.txt

Assembly (file *does* exist):
C:\Users\<user>\AppData\Local\NCrunch\8648\1\<project>\bin\Debug\<file>.txt


To accommodate this difference, check both paths for the file in question and all test runners should be able to find the file.
dariusdamalakas
#5 Posted : Tuesday, March 28, 2017 1:59:04 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/10/2013(UTC)
Posts: 42
Location: Lithuania

Thanks: 4 times
Was thanked: 5 time(s) in 5 post(s)
Got same issue. NCrunch for VS 2015, 3.6.0.2

-- Files are copied here:
C:\Users\<user>\AppData\Local\NCrunch\11640\30\src\<service>


-- but the files need to be in here. Resharper does work fine.
C:\Users\<user>\AppData\Local\NCrunch\11640\30\test\<service>.Tests\bin\Debug
dariusdamalakas
#6 Posted : Tuesday, March 28, 2017 2:02:48 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 1/10/2013(UTC)
Posts: 42
Location: Lithuania

Thanks: 4 times
Was thanked: 5 time(s) in 5 post(s)
Actually, the files were copied because i added to copy them manually via config - but the files end up in src folder, not under bin/debug.
This is a blocker for me, as i have to revert to using ReSharper, and not NCrunch
Remco
#7 Posted : Tuesday, March 28, 2017 9:28:37 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,976

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi,

Can you share any more details about these files? Are they specified in your test project, or in a project referenced by your test project? Where do they exist relative to the test project file?

If the files are declared in a project referenced by your test project, there is a limitation here you should be aware of - http://www.ncrunch.net/documentation/considerations-and-constraints_assembly-colocation-assumptions.
andrepires
#8 Posted : Monday, February 17, 2020 3:53:08 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/11/2015(UTC)
Posts: 1
Location: Brazil

Hi. I had the same issue.
On Visual Studio, setting the files Build Action to Copy Always and Copy to Output Directory to Copy Always solved the problem.
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.068 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download