You probably want to make a similar change to the run function above, and to the nuget function as well, as well as collecting the processes and waiting for the outputs of the nuget executions.

That would probably let you remove the sleep below.