Friday, March 28, 2014

NuGet - Update Process for Package Restore

Recently I discovered that NuGet has dramatically simplified package restore, but no one told me.  

The NuGet team has provided the following document Migrating to Automatic Package Restore.

I'll provide the abbreviated document here.

The Previous Method
Right right click on your solution in visual studio choosing >> Enable package restore. This created a .nuget folder containing the nuget.exe etc. Your .csproj or .vbproj files were modified with an <import /> tag containing a NuGet path.

This triggered automatic package restore upon a build of your solution. Thankfully, this is no longer necessary!

The New way to do package restore 
You do nothing. Unless you’re building from the command line, in which case you run 'nuget restore' before msbuild.

Using this method with SVN Externals 
When using SVN externals, often you may only want to pull one project from a solution, into another solution as an external. Unfortunately, this breaks the NuGet package restore system, as package restore is based at the solution level.

Currently I’ve only come up with one simple method. In your SVN externals, reference the entire solution from which you only want one project. Open the solution that is downloaded as your external reference and build it. Now packages are restored, and you may use the one project you actually want to reference externally. Seems quite wrong doesn't it?  Hope the NuGet team keeps working on finding better ways for scenarios such as the above...

No comments:

Post a Comment