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

Notification

Icon
Error

very long time to build new workspace - possibly the cause is nuget
thirkcircus
#1 Posted : Wednesday, May 2, 2012 8:42:30 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/8/2012(UTC)
Posts: 8
Location: NZ

Was thanked: 1 time(s) in 1 post(s)
hi,

i have a large solution (~70 projects) which is taking a very very long time (for ncrunch) to initialise building of projects.
not sure why this is, couple of thoughts which might be relevant:

  1. Each project takes on average, upwards of 1min 30sec to build the assembly. Almost all of this time appears to be in building the workspace.
  2. I see each project gets its own subdir in the ncrunch working dir. Each project has an entire copy of the 270MB nuget packages dir from the solution. Why is this? This (copying the packages dir) is presumably what is causing building a workspace to take so long. I can see the _ncrunchreferences dir should(?) contain all the required refs for the project - so why are the nuget packages being brought along as well?
  3. To shorten the build time I've got a custom solution config DebugFast which a) doesn't run the codecontracts rewriter and b) doesn't try to restore nuget packages. Am I right in thinking that ncrunch doesn't try to restore nuget packages anyway?
  4. I have made some small modifications to the .nuget\nuget.targets solution file. I presume that shouldn't affect ncrunch - although each ncrunch proj working dir does have the .nuget dir (and as mentioned the packages dir) so i wonder if ncrunch is getting mixed up with nuget somehow.
  5. Once the workspace is set up, building is as quick as I'd expect. It's setting up the workspace that is taking ages.
  6. copy of a single project ncrunch build log:
    [18:03:09.005-BuildTask-72] Launching task: [BuildTask: [SnapshotComponent: MyProject.Tests, 8, 55829439], BeingProcessed]
    [18:03:09.027-BuildTask-72] Building new workspace d:\ncrunch\10068\121\ for component MyProject.Tests
    Note how long (45s) it takes to build the workspace...
    [18:03:54.961-BuildTask-72] Registered usage of workspace: d:\ncrunch\10068\121 (now 1 usages)
    [18:03:54.97-BuildTask-72] Now building MyProject.Tests
    [18:03:54.972-BuildTask-72] Returning process 10936 from pool with signature: [ProcessSignature:
    Compiler
    nCrunch.Compiler.RemoteBuildRunner
    nCrunch.build.4.0.config
    x86

    Framework4_0

    ]
    [18:03:59.17-BuildTask-72] Storing process 10936 in pool
    [18:03:59.17-BuildTask-72] Adjusted assembly references for this project are as follows:
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\83\Shared\Common\bin\DebugFast\MyCompany.MySolution.Common.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\86\MyProject\MyProjectService\MyProjectApi.Contracts\bin\DebugFast\MyCompany.MySolution.MyProject.MyProjectService.MyProjectApi.Contracts.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\8\Tests\Tests.Common\bin\DebugFast\MyCompany.MySolution.Tests.Common.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\101\MyProject\MyProjectService\MyProjectService.Client\bin\DebugFast\MyCompany.MySolution.MyProject.MyProjectService.Client.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\85\MyProject\MyProjectService\MyProjectService.Contracts.Data\bin\DebugFast\MyCompany.MySolution.MyProject.MyProjectService.Contracts.Data.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\94\MyProject\MyProjectService\MyProjectService.Contracts\bin\DebugFast\MyCompany.MySolution.MyProject.MyProjectService.Contracts.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\103\MyProject\MyProjectService\MyProjectService.Secure.Contracts\bin\DebugFast\MyCompany.MySolution.MyProject.MyProjectService.Secure.Contracts.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\115\MyProject\MyProjectService\MyProjectService\bin\DebugFast\MyCompany.MySolution.MyProject.MyProjectService.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\121\_ncrunchreferences\Machine.Specifications.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\121\_ncrunchreferences\Moq.dll
    [18:03:59.17-BuildTask-72] C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\121\_ncrunchreferences\Ninject.dll
    [18:03:59.17-BuildTask-72] d:\ncrunch\10068\121\_ncrunchreferences\Ploeh.AutoFixture.dll
    [18:03:59.17-BuildTask-72] C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Core.dll
    [18:03:59.17-BuildTask-72] C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll
    [18:03:59.17-BuildTask-72] C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.ServiceModel.dll
    [18:03:59.17-BuildTask-72] Project configuration is:
    [18:03:59.17-BuildTask-72] IgnoredTests=nCrunch.Core.Configuration.ITestSelector[]
    [18:03:59.17-BuildTask-72] HiddenWarnings=System.String[]
    [18:03:59.17-BuildTask-72] CopyReferencedAssembliesToWorkspace=False
    [18:03:59.17-BuildTask-72] ConsiderInconclusiveTestsAsPassing=False
    [18:03:59.17-BuildTask-72] IgnoreThisComponentCompletely=False
    [18:03:59.17-BuildTask-72] RunPreBuildEvents=False
    [18:03:59.17-BuildTask-72] RunPostBuildEvents=False
    [18:03:59.17-BuildTask-72] PreviouslyBuiltSuccessfully=True
    [18:03:59.17-BuildTask-72] InstrumentAssembly=True
    [18:03:59.17-BuildTask-72] PreventSigningOfAssembly=False
    [18:03:59.17-BuildTask-72] AnalyseExecutionTimes=True
    [18:03:59.17-BuildTask-72] IncludeStaticReferencesInWorkspace=True
    [18:03:59.17-BuildTask-72] DefaultTestTimeout=60000
    [18:03:59.17-BuildTask-72] AdditionalFilesToInclude=System.String[]
    [18:03:59.17-BuildTask-72] UseBuildConfiguration=DebugFast
    [18:03:59.17-BuildTask-72] ProxyProcessPath=
    [18:03:59.17-BuildTask-72] UseCPUArchitecture=AutoDetect
    [18:03:59.171-BuildTask-72] Using config file: d:\ncrunch\10068\121\Tests\MyProject.Tests\bin\DebugFast\MyCompany.MySolution.Tests.MyProject.Tests.dll.config
    [18:03:59.197-BuildTask-72] Build was successful for d:\ncrunch\10068\121\Tests\MyProject.Tests\bin\DebugFast\MyCompany.MySolution.Tests.MyProject.Tests.dll
    [18:03:59.198-BuildTask-72] Task processing complete for [BuildTask: [SnapshotComponent: MyProject.Tests, 8, 55829439], BeingProcessed], processing time: 00:00:22.5660000


I'm guessing it's the nuget/packages copy which is blowing processing times out - any ideas why this is?

thanks
justin
thirkcircus
#2 Posted : Wednesday, May 2, 2012 8:48:41 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/8/2012(UTC)
Posts: 8
Location: NZ

Was thanked: 1 time(s) in 1 post(s)
oh.
writing that post made me think of some better search terms. just searched the forum again, found this: http://forum.ncrunch.net...th-a-200mb-solution.aspx
i guess that's the answer then.
70 * 270MB = a lot of disk thrashing... :|
I don't see a way round this except for ncrunch to handle nuget packages/refs a bit more smartly. do you agree?

btw, once the packages have been copied over (to each proj) once, will ncrunch do this again? I know it creates a new workspace if I change the ncrunch settings for a project. But if I close, reopen solution will nuget use the existing workspaces?
Remco
#3 Posted : Wednesday, May 2, 2012 10:09:26 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi,

You're absolutely correct with all of the above. NCrunch is copying all the nuget references into each isolated workspace for each component, and this creates a lot of grinding. It also uses a lot of disk space.

NCrunch won't recopy the nuget packages again once the engine is properly wound up, but it will nuke all the workspaces when the engine is disabled - so every time you restart the IDE you're in for a long wait.

It's difficult to find a correct answer to a problem like this - basically because Nuget needs to keep the packages list up to date, and NCrunch needs isolated workspaces. The main problem comes down to Nuget auto package restore. If NCrunch doesn't copy the nuget packages into the workspace and Nuget package restore is enabled, Nuget will automatically open a connection to its home server in order to refresh and redownload the packages. Naturally this gives a massive increase to initial build times when workspaces are being created.

A solution I am considering right now is as follows:

1. If a user has Nuget auto package restore disabled, NCrunch will avoid copying the Nuget packages to the workspace and simply copy the binaries that are being used instead. This should mean that the problem you are experiencing will not exist.
2. If a user has Nuget auto package restore enabled, NCrunch will copy the Nuget packages to each workspace and present a warning to the user informing them that their initial workspace build times may be higher because of the need to support Nuget auto package restore.

Would this solution work for you?


Cheers,

Remco
thirkcircus
#4 Posted : Wednesday, May 2, 2012 11:04:25 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/8/2012(UTC)
Posts: 8
Location: NZ

Was thanked: 1 time(s) in 1 post(s)
hi,

yes, sort of. ;)

For my solution I have a Debug configuration (nuget package restore enabled) and DebugFast configuration.
The nuget targets file has the following modification in it:
<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(RestorePackages) == 'true' AND '$(Configuration)' != 'DebugFast'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>
So if I know that all the nuget packages are already pulled down (usually by running a Debug build at some point) I can then build the solution with DebugFast config => don't have to go through the additional time that it takes for nuget to even check that packages exist. Saves quite a bit of time.

What would be really helpful would be a ncrunch solution config setting to tell it to ignore package restore. That way I can tell ncrunch to build the solution with Debug config but not copy the nuget packages. If ncrunch can do this without my having to alter my solution config then I get the best of both worlds:
  1. Run Debug build of solution and have it verify/restore nuget packages like normal
  2. Run ncrunch with Debug config while (via ncrunch config) skipping the nuget package verify/restore and just pulling the binaries


sorry, that's all a bit wordy...
What you are suggesting is almost what I want - but I don't want to have to change my solution config to take account of ncrunch.
just a config setting in ncrunch which turns off the package restore would be great. :)
thirkcircus
#5 Posted : Wednesday, May 2, 2012 11:05:33 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/8/2012(UTC)
Posts: 8
Location: NZ

Was thanked: 1 time(s) in 1 post(s)
so when ncrunch runs msbuild, can't you just pass in a property?
$(RestorePackages) = false
Remco
#6 Posted : Wednesday, May 2, 2012 11:47:40 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
This is possible, but then there is the underlying question of why a user would be making use of nuget package restore.

The main reason I could think of is if they were working with a solution under which all Nuget packages had been deliberately left out of source control. In this case, there is no guarantee that when NCrunch runs it will actually have the packages to work with. This could create obscure problems in environments with new members joining a team to work on an unfamiliar system.

I guess the main situation I'm trying to avoid is where NCrunch throws a random error that is actually related to the solution configuration/state and it gets blamed for it (NCrunch gets much criticism for these kind of problems).

The ideal would be if NCrunch were able to detect the presence of all packages then give a meaningful error informing the user that they need to restore nuget packages. This is unfortunately also the most difficult to implement because it means much closer integration with Nuget to establish reliable logic that can identify when any required packages are missing.

Maybe the best is to just implement a switch to disable package restore and hope that no one complains when they pick up an unfamiliar solution and crazy things happen...
thirkcircus
#7 Posted : Thursday, May 3, 2012 12:51:42 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/8/2012(UTC)
Posts: 8
Location: NZ

Was thanked: 1 time(s) in 1 post(s)
well, that solution would work fine for me. ;)

yeah, i see what you mean though. If the packages aren't there to begin with then you're kind of screwed unless you know to run a full build (to restore the packages) first.
i guess at the very least you (ncrunch) could check to see if the sln packages dir is empty and show a warning - that would pick up the situation where someone new to the team has loaded up the sln for the first time.

what about a simple button in ncrunch to verify all the packages exist?
that could just shell out to the nuget command line - much like we do on our build server...
step 1:
foreach ($project in get-project -all){
# trivial 1-liner to run nuget commandline to verify/restore packages for project into the ncrunch workspace for that project
}
step 2:
build solution with restore packages turned off via msbuild switch

that way users have an easy resolution if ncrunch falls over because nuget packages aren't available in the workspace.
Remco
#8 Posted : Thursday, May 3, 2012 1:16:35 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
I like your idea of showing the message if the packages dir is empty or missing. To me this would probably catch around 99% of the error cases and could give a meaningful message asking the user to rebuild their solution before enabling NCrunch.

I'll see what I can do about implementing this properly as a fix. Thanks for your help.
Remco
#9 Posted : Sunday, May 20, 2012 11:29:12 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
For anyone interested, the recently released v1.39b contains a fix that should greatly reduce the disk consumption of solutions that are using Nuget.
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.098 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download