Read output streams before calling WaitForExit() to avoid a deadlock for packages with many dependencies.

For packages with many dependencies the output stream from calling NuGet.exe in functions/Run-NuGet can be filled and cause a deadlock [as described on MSDN][1].

Moving the call to WaitForExit() to after the output streams have been read solves this problem.

[1]: http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx
Yes, a deadlock will occur if the child process (nuget in this case) alternates between writing to standard error and standard output and writes enough data to exceed the size of the buffer of one of the pipes created under the covers.
A reliable solution would be to register for the OutputDataReceived and ErrorDataReceived events (using Register-ObjectEvent) and use async reads (BeginOutputReadLine, BeginErrorReadLine).