Thursday, March 27, 2014

Migrate away from MSBuild-based NuGet package restore

Very nifty trick. In the end, your solution will look like the following. Note the .nuget folder has only a NuGet.Config file:


Link: http://www.xavierdecoster.com/migrate-away-from-msbuild-based-nuget-package-restore.
Here are the instructions on how to undo it: http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore. Note: where the article says "using TFS," read it as "using version control" because the instructions also apply to Git.

Update 4/4/14: You might have to close the solution and delete any .suo files or Visual Studio will stubbornly bring back the .csproj settings that you deleted.

Update 4/9/14: This doesn't appear very stable when using version control features where you backtrack in history -- for instance to merge a feature branch. Visual Studio stubbornly resurrects the import and target tag in the project file, and killing this won't work unless you first close the solution and delete the .suo file.

I'm actually considering moving back to NuGet package restore. At least it's reliable.

Second update 4/9/14: This doesn't play well with ReSharper's cool feature where it automatically adds NuGet packages to a project instead of just a reference.