Visual Studio command for auto reinstall/restore all packages

Topics: Ecosystem
Apr 23, 2014 at 11:24 PM
The issues around nuget.exe being useless for build machines are well known since it doesn't execute any of the scripts. A common scenario for that is a managed DLL that has native DLL dependencies. In my specific case, the native DLLs are architecture-specific so I actually have to copy the x86 and x64 subfolders to the project output directory so it can select the appropriate one via assembly binding at startup. (This DLL is commonly already in the GAC on customer sites but with an incompatible version, or the native DLLs have bad versions in the path so it all gets very complicated).

I just went through moving all our dependencies to nuget, only to find out it is useless because we can't use it on the automated build server.

I thought hey, I'll just write a macro to drive the Package Manager Console window, but they removed macros from VS 2012.

But a thought hit me... You can run a command in VS by running "devenv.exe /Command <name>".

If nuget had a command that was essentially "restore all solution packages and re-install them" then we could work around the command line issue by calling that command from a build script. In fact I could see the usefulness of having a couple of commands:
  • Restore all packages
  • Restore and reinstall all packages
  • Update all packages
  • Update and reinstall all packages
Yes, you have to have VS installed on the build server, but that's far better than "there is no command-line story for nuget, too bad so sad or write separate utility programs to duplicate your script logic".