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

Notification

Icon
Error

How to enable NuGet Package Restore with NCrunch?
tjahn
#1 Posted : Friday, April 24, 2015 10:56:51 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/24/2015(UTC)
Posts: 9
Location: Germany

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
Is there a way to use the Command-Line Package Restore technique for NuGet with NCrunch? I would like to avoid the MSBuild-Integrated Package Restore (see this post for some reasons).
Remco
#2 Posted : Friday, April 24, 2015 11:46:44 AM(UTC)
Rank: NCrunch Developer

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

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

NCrunch doesn't function well with Nuget package restore (command-line, MSBuild or otherwise), as it needs to build new workspaces regularly to be able to build and run tests in parallel. Since these workspaces are effectively clones of your source project, newly creating them simply means that Nuget needs to restore the packages again and again, greatly slowing down the build and increasing the amount of disk space unnecessarily allocated to the workspaces.

When working with NCrunch, you should always restore your packages inside the foreground solution instead. NCrunch will detect the changes made by packages being restored and should resynchronise accordingly. In any even that Nuget operations cause a desync, simply resetting the engine will bring it back into line.
tjahn
#3 Posted : Friday, April 24, 2015 1:07:51 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/24/2015(UTC)
Posts: 9
Location: Germany

Thanks: 1 times
Was thanked: 3 time(s) in 3 post(s)
Thank you for the quick reply! I was not aware of the fact that NCrunch indeed uses the local NuGet Package Repository directory if it contains the necessary assemblies (which Visual Studio ensures on first build).

Running a build from Visual Studio as a workaround in the situation where a NuGet package is missing is a viable workaround for me. Thanks again!
Remco
#4 Posted : Friday, April 24, 2015 1:13:53 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
tjahn;7254 wrote:
Thank you for the quick reply! I was not aware of the fact that NCrunch indeed uses the local NuGet Package Repository directory if it contains the necessary assemblies (which Visual Studio ensures on first build).


There are sometimes situations where NCrunch can't correctly detect all the Nuget dependencies of a project. This can sometimes result in build errors. If you get hit by this, just include the relevant Nuget paths using the Additional files to include project-level configuration setting.
Jduff
#5 Posted : Wednesday, September 23, 2015 3:17:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/18/2015(UTC)
Posts: 3
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
"When working with NCrunch, you should always restore your packages inside the foreground solution instead"

Sorry for the newbie question but can you explain this please? I'm trying to work w/command line nuget and need a way to get the nuget packages restored.

Thanks.
Remco
#6 Posted : Wednesday, September 23, 2015 10:58:26 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Jduff;7760 wrote:
"When working with NCrunch, you should always restore your packages inside the foreground solution instead"

Sorry for the newbie question but can you explain this please? I'm trying to work w/command line nuget and need a way to get the nuget packages restored.

Thanks.


NCrunch has two kinds of 'solutions' it works with (when you're not using distributed processing):

1. The 'foreground' solution - this is the solution that you open up in Visual Studio and make changes to. It's effectively your codebase. NCrunch will never make modifications to it but it will read any changes that are made and synchronise them into ...

2. The 'background' solutions / workspaces. These are virtual projects/solutions that are constructed inside a separate working area of your hard disk. NCrunch modifies these routinely to create transient copies of your source code. When NCrunch builds your projects and runs tests, it will do so here.

Because the 'foreground' solution is the source of all data for NCrunch, it's reliant on this solution to contain everything it needs to build your projects. In earlier versions of the product, NCrunch had no knowledge of Nuget and did not attempt to override any build steps. This meant that when NCrunch loaded up a foreground solution without the Nuget dependencies restored, Nuget would then attempt to restore its packages inside the background workspaces, which was very slow and inefficient. To prevent this from happening, NCrunch will now suppress the automatic package restore of Nuget inside background workspaces.

This means that for NCrunch to work, it needs to have all the Nuget dependencies restored inside your foreground solution. Otherwise, it will complain about missing dependencies and it won't be able to build your projects. The rule of thumb here is that if your foreground solution can build inside Visual Studio (without NCrunch involved), then you're OK here, as all the dependencies will have already been restored. If your foreground solution won't build in Visual Studio and Nuget is giving you errors, then NCrunch won't have any way to solve this for you with its own background processing.
Jduff
#7 Posted : Thursday, September 24, 2015 1:19:30 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 9/18/2015(UTC)
Posts: 3
Location: United States of America

Was thanked: 1 time(s) in 1 post(s)
Thanks, that makes sense.

Now, my solution does build in VS without ncrunch as well as msbuild from the command line and I can see the nuget references getting restored. However, when running with ncrunch from the command line it is obvious that the nuget references are not getting restored. I'm likely missing something with ncrunch obvious here but am not sure what it is.
Remco
#8 Posted : Thursday, September 24, 2015 9:00:02 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
It's likely that your problem isn't related to the restoration of Nuget packages, and is probably just an implicit build reference into other areas of the package. Try including your Nuget 'packages' directory using the NCrunch solution-level 'Additional files to include' setting. This will instruct NCrunch to copy ALL the Nuget package resources into each workspace.

If this solves the problem, you can then narrow down the dependency to specific files to include instead, as copying all Nuget packages into each workspace can slow the engine down a bit.
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.058 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download