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

Notification

Icon
Error

NCrunch using out-of-date / non-compiling source files
SimonOBeirne
#1 Posted : Monday, March 5, 2012 8:36:17 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/5/2012(UTC)
Posts: 4
Location: UK

I'm using v1.37.0.46b in VS2010 - and I must say its not often I'm blown away by something, but NCrunch has certainly done just that over the last week or so.

However I got a problem which has occured a few times today where NCrunch has been using an older version of the source files to those in my solution, specifically a version which doesn't compile and therefore stops all tests from running.

The solution has the following projects:

  • 2 x VB Windows App
  • 1 x C# Web Application
  • 2 x C# Class Library (one with classes (lets call it A), one with tests (B))
  • 1 x C# Windows App

My tests are currently in one of the C# projects (B), and only reference the other C# class library project (A). The referenced project has <10 classes in it, and so far I've got 3 test classes in project B.

NCrunch appears to have been trying to use a previous (non-compiling) version of two of my class files (in project A), both of which had XmlElement attributes decorating the class (causing the compile error), which have since been changed to [XmlRoot]. I've checked the working folder, and the files are definitely the wrong ones.

Things I've tried which haven't helped (that I can see):
  1. Set all projects, other than the two C# class library projects I care about, to "Ignore this component completely".
  2. "Rebuild selected component" from context menu

I played around for a bit and found two solutions:
  1. One involved cleaning the solution and individual projects (I'm not sure which worked), before then rebuilding the relevant projects and giving NCrunch a boot (resync / restart process).
  2. The other was to simply update the files in question, which NCrunch then recognised and picked up the latest versions.

Interestingly, I've just switched back to VS2010 and I'm getting the same errors as previous, despite having fixed them earlier with the second solution above. I doubt the errors are relevant, but I've included them below just in case:

[20:23:40.6994-BuildTask-59] ERROR (Compilation): RAC.Integration.Shared: PDD\PaperlessDirectDebit.cs (9): Attribute 'XmlElement' is not valid on this declaration type. It is only valid on 'property, indexer, field, param, return' declarations.

[20:23:40.6994-BuildTask-59] ERROR (Compilation): RAC.Integration.Shared: PDD\PaperlessDirectDebitList.cs (9): Attribute 'XmlElement' is not valid on this declaration type. It is only valid on 'property, indexer, field, param, return' declarations.

One final thing... I just cleared out all previous versions from the working directory. NCrunch failed with multiple "Can't find file X" errors. I resync'd / restarted NCrunch from within visual studio, forced a rebuild of project A, and it failed again with the same errors as above!! Very odd... no idea where that code is, but its clearly cached somewhere.

If you need any more info - let me know!

Simon
Remco
#2 Posted : Tuesday, March 6, 2012 12:14:19 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 941 times
Was thanked: 1265 time(s) in 1177 post(s)
Hi Simon,

Thanks for posting! Version related issues like this can be tough to track down as they are often workflow dependent, but with persistence I'm sure we can fix this.

The reset button will often be your best friend for this situation where it can occur, as this will cause NCrunch to blow away all of its workspaces and cache, reconstructing them from scratch.

The first thing for us to check would be the manner in which Project B is referencing Project A. Have a look at Project B's .csproj file in any text editor - does it use a <ProjectReference> or a <Reference>? If it's using a <Reference>, then this will create abnormal referencing behaviour between your projects and may cause the problem you've described above.

If this isn't the case (and you're using <ProjectReference>), then I think the best plan would be for me to take a look at the NCrunch log file leading up to the point of failure (assuming you can recreate it consistently). The 'Submit Bug Report' option in the 'NCrunch' menu will send through this log file for me to take a look at. Hopefully this will give me enough information to work out what is going on :)


Cheers,

Remco
SimonOBeirne
#3 Posted : Tuesday, March 6, 2012 6:02:17 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/5/2012(UTC)
Posts: 4
Location: UK

Hi Remco,

Thanks for the quick response.

I think by "reset button" you mean the "Resychronise, rebuild and run all tests (reset)" button?

Unfortunately even that doesn't resolve the issue; and I've checked the workspace and it still has the old code in it.

Have just submitted the bug info from within VS - I'd be interested to hear how you get on.

Simon
SimonOBeirne
#4 Posted : Tuesday, March 6, 2012 6:03:21 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/5/2012(UTC)
Posts: 4
Location: UK

Oops - forgot to say, the unit test project (project B) is referencing project A using a "ProjectReference".

Simon
Remco
#5 Posted : Tuesday, March 6, 2012 6:31:07 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 941 times
Was thanked: 1265 time(s) in 1177 post(s)
Thanks - I'll take a look at the log file and will get back to you :)
Remco
#6 Posted : Tuesday, March 6, 2012 8:47:40 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 941 times
Was thanked: 1265 time(s) in 1177 post(s)
Hi Simon,

Something I forgot to ask is whether you have any customisations in place as part of your build process. For example, do you make use of any pre/post build steps, 3rd party SDKs or frameworks, overridden build targets, or anything that could be considered out of the ordinary?

Is there anything unusual about how the failing source files are referenced from the .csproj file? Are these source files different in some way? (i.e. manipulated by a designer of some sort in VS, instead of through source code)
SimonOBeirne
#7 Posted : Tuesday, March 6, 2012 9:32:27 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/5/2012(UTC)
Posts: 4
Location: UK

Nope - all standard projects, no Pre/Post build steps etc.

One of the VB projects references an old COM component, but I've excluded that project already so wouldn't have thought it'd be that.

One thing I did just think of is that I installed VS11 / .NET 4.5 beta's on Friday evening. These projects are .NET 4.0, so the 4.5 upgrade may have had some impact on compilers... but the fact that that NCrunch workspace versions are out-of-sync would suggest the problem earlier in the process / pre-compile.

Simon
Remco
#8 Posted : Tuesday, March 6, 2012 8:50:32 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 941 times
Was thanked: 1265 time(s) in 1177 post(s)
The thing that doesn't make sense to me is where the old version of the code is coming from. Basically, NCrunch stores your code in two places:

1. In memory, inside Visual Studio - this is updated on the fly as you make changes to a project, and naturally this would be cleared when you restart VS
2. In the NCrunch workspaces directory - this gets written from the code in memory just prior to a build being initiated, and several different copies can exist at one time. Normally NCrunch will clear this out when you hit reset or restart the IDE, though 1.37b does have a known issue where sometimes workspaces are being left behind if they contain read-only files (in which case the workspace will simply sit there defunct and will not be used by NCrunch).

So if you've made an update to your codebase and restarting the IDE still gives you build issues pointing back to the old code, this suggests to me that somewhere there must be an earlier version of your source code that is being referenced from your solution.

Can you try the following and let me know of the results?

- Create a new empty class file in the failing project
- Copy/paste the contents of the failing source file into the new empty class file (assumption here is that the copied content contains the fixed up code which should actually be working)
- Exclude/remove the original failing source file from the project
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