4
votes

I am having trouble with very slow builds in a solution with 12 projects out of which 7 have NuGet Package Restore enabled. The diagnostic output typically displays this:

    [...]
    9 ms  ResolveProjectReferences                   1 calls
   18 ms  _CleanGetCurrentAndPriorFileWrites         1 calls
   32 ms  CoreClean                                  1 calls
   56 ms  ResolveAssemblyReferences                  1 calls
   77 ms  _CopyFilesMarkedCopyLocal                  1 calls
  400 ms  CoreCompile                                1 calls
 9082 ms  RestorePackages                            1 calls

This is typical; RestorePackages usually takes 9-10 seconds for every project, and with 7 projects this adds a hefty 70 seconds to my build time. None of my colleagues who build the same solution has this problem. I have disabled all extensions and Visual Studio (2012) is up to date.

I have filed an issue on CodePlex, but I also want to ask this knowledgeable community in case there is a quickfix, and to seek help in troubleshooting this issue.

Edit: I completely removed NuGet -- the RestorePackages target is still being executed, and it still takes 10 seconds. I need to manually set RestorePackages = false in the csproj files to make this go away.

Edit 2: If I comment out the contents in the RestorePackages task in NuGet.targets the problem goes away too. Like this:

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
    <!--<Exec Command="$(RestoreCommand)"
          Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />

    <Exec Command="$(RestoreCommand)"
          LogStandardErrorAsError="true"
          Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />-->
</Target>

It does not make a difference if I remove the CheckPrerequisites target.

Edit: I installed Windows 8.1, problem does not occur anymore.

2
The timeout for connecting to the package servers is 10 seconds by default. You probably had a server in your nuget.config that couldn't be connected to. The restore might have still worked because of the cache of packages on your local disk.Owen Johnson

2 Answers

0
votes

I don't think it is a build issue. Try to manually execute the NuGet.exe passing in your from command line and you will probably see that it takes the same amount of time.

In the past, I have had this issue of NUGet package downloading contents all the time if I have some resource files (images, etc.) in my projects where the "Copy to Output Directory" is set to "Copy always". If you have this, try changing it to "Copy if newer".

0
votes

Sometimes it can be painfully slow, like yesterday.
You can check the status of the services here.