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

Notification

Icon
Error

Getting build errors after a delay - project builds and runs fine
MrTortoise
#1 Posted : Wednesday, August 15, 2012 10:24:46 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2012(UTC)
Posts: 1

Its odd, sat down and looked and cant figure out why

Basically I have a solution with a test project (suprise!)
I have nuget set up and none of the nuget packages in source control - but they are in the packages folder for the solution.

The whole solution builds fine (and the tests run and pass)
But whilst i am editing code in another project the test project will suddenly fail with all kinds of type conversion errors related to assemblies not being found. they all relate to external and internal nuget packages.

Of course i can build and they go away ... but 54 errors is kind of irritating and will really confuse the junior devs.

everything was and has been working fine until i removed the nuget packages from source control (which is my preferred configuration).

any ideas?

Edit: looks like its my fault ... am investigating my end
Remco
#2 Posted : Wednesday, August 15, 2012 9:43:21 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 posting!

The first thing that always comes to mind when I hear about intermittent build errors is to try removing as much complexity from your build process as possible. This means that if you're using custom build steps or 3rd party frameworks, try disabling these to see if the problem goes away. Make sure you don't have any absolute path references from your code that could reach out of the NCrunch workspace and go back to the original (unshadowed) solution.

NCrunch doesn't really 'know' anything about source control in itself, so most likely there's been another change (or something related that's been affected) beyond your removal of files from source control.

Note that NCrunch won't automatically restore nuget packages if it is enabled without them being present. This can create an interesting situation where NCrunch workspaces can exist without the files, requiring a full foreground rebuild of your solution (so that nuget can restore the references), then a Reset of the NCrunch engine in order to fix.
dc-storm
#3 Posted : Wednesday, November 7, 2012 12:11:35 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/7/2012(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
@Remco

I'm trying to follow your instructions on how to fix the NCrunch configuration, but without success. To refresh your memory, when NCrunch initialises, after opening the solution for the first time, I'm trying to get NCrunch to allow NuGet to restore missing packages.

I've tried disabling NCrunch and then rebuilding the solution, then re-enabling NCrunch but after closing down the solution, deleting the packages NuGet restored and opening the solution again, NCrunch initialises again but fails to call the NuGet restore process. I've also tried setting the build configuration for the projects within the NCrunch > Configuration option, but they too don't seem to restore the NuGet packages.

Can you help me out please?

jason [at] dc - storm [dot] com

Thanks.
Remco
#4 Posted : Wednesday, November 7, 2012 8:42:15 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 Jason -

NCrunch deliberately disables Nuget package restore as part of its own build process, as this feature introduces serious performance problems within NCrunch.

Essentially, Nuget package restore involves the build process reaching out to the Nuget server and downloading any missing packages. Because NCrunch creates many workspaces for an open solution, this activity is then performed many times and NCrunch builds grind to a halt. This is a design issue between the ways that NCrunch and Nuget both work, and there is no feasible way to solve this problem in the tools themselves.

When using NCrunch on a solution where you rely on Nuget package restore, ensure you always first perform a Visual Studio build so that Nuget can download the package dependencies before you turn on NCrunch. In this way you shouldn't experience any problems.


Cheers,

Remco
dc-storm
#5 Posted : Friday, November 9, 2012 5:17:40 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/7/2012(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
@Remco

Thanks, mate. Shame NCrunch can't perform the re-build in VS, then listen for it to complete before running tests.

With regard to the NCrunch configuration UI, does the 'Use build configuration' property actually work? Since if it did, I could then call the custom configuration that has the package restore task included.

Ta,
Jay
Remco
#6 Posted : Friday, November 9, 2012 8:57:22 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 Jay,

Use Build Configuration does allow you to inject a custom $(Configuration) property into the NCrunch build, but there is a better way for your to introduce conditional build logic when using NCrunch.

Try the $(NCrunch) environment variable. For example:
Condition="'$(NCrunch)' == '1'"


Cheers,

Remco
dc-storm
#7 Posted : Monday, November 12, 2012 11:15:37 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/7/2012(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
@Remco

Thanks for the advice. In order to re-enable the restore packages task, I've manually edited the project files to call the restore command line as the BeforeBuild task. With the condition being if NCrunch is running.

When testing this without the Condition statement, the packages seemed to download as the Solution was being opened ("Preparing solution..." message screen), which actually works better for me as then I don't require any NCrunch linked edits within the project.

Might be hopeful for anyone else attempting to set up this development configuration.

Jay
Remco
#8 Posted : Monday, November 12, 2012 8:01:08 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 Jay -

I'm pleasantly surprised that this works ... so much so that I may add it as a feature. Can you show me the code you've injected into the project file? I'd really like to take a closer look.


Thanks!

Remco
dc-storm
#9 Posted : Tuesday, November 13, 2012 3:05:49 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/7/2012(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
@Remco

Sure thing, I'm pretty busy at the moment, but I'll dig out the repository for it either later today or tomorrow.

Jay
1 user thanked dc-storm for this useful post.
Remco on 11/13/2012(UTC)
dc-storm
#10 Posted : Wednesday, November 21, 2012 7:47:47 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 11/7/2012(UTC)
Posts: 5
Location: United Kingdom

Was thanked: 1 time(s) in 1 post(s)
@Remco

Sorry for the long delay. It turns out that in my investigation, the reason Visual Studio kept downloading NuGet packages automatically when opening the solution was because it had detected a change had been done to the project file.

So there's no magic msbuild tasks that'll automatically restore packages, but if you were to implement any change to the project file structure, even a timestamp, that would force Visual Studio to magically restore all referenced NuGet packages. Hint, hint.

On a side note, is there any chance NCrunch can send another parameter to MSBuild, which would be the original Solution directory for which NCrunch is now building. I realise that NCrunch creates a copy of the project, but it would help me restore NuGet packages if I was able to know the original solution directory that the copy was take from.

Jay
Remco
#11 Posted : Wednesday, November 21, 2012 10:04:09 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 Jay,

Thanks for getting back to me on this. Modifying the project file in its original solution location is something I'm not sure if I want to tangle with - as so far NCrunch has managed to avoid any situation where it actually manipulates your original source code. I might have a bit of a look into this later to see if there's another way I can kick the nuget package restore.

The MSBuild parameter pointing to the original solution location has been heavily requested and is in the plan for the 1.43 release due out in a few weeks time. I hope you'll be able to make good use of this one when it becomes available :)


Cheers,

Remco
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.073 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download