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).
Build/Test Issues
How to enable NuGet Package Restore with NCrunch?
Started by tjahn on 10,061 views
Remco NCrunch Developer
#7253
24 Apr 2015 11:46 UTC
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.
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.
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!
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 NCrunch Developer
#7255
24 Apr 2015 13:13 UTC
tjahn 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.
"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.
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 NCrunch Developer
#7763
23 Sep 2015 22:58 UTC
Jduff 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.
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.
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 NCrunch Developer
#7765
24 Sep 2015 21:00 UTC
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.
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.
Post a reply
Log in to reply.