Monday, August 13, 2012

Disable NuGet Package Restore

Enabling the NuGet  package restore feature is easy. Just right click on your solution inside Visual Studio and choose the 'Enable NuGet Package Restore' option.

However what if you want to disable this again? I couldn’t find an option to do this, so let’s investigate all the changes that this option made.

First it added a .nuget folder containing a nuget.targets file and nuget.exe. So we’ll start by removing this folder and all its content from your solution.

Second it added an import to this target file to all your projects that are using NuGet packages. To remove this import right click on each project and choose unload project. Right click then on the csproj file and choose the Open with… option from the context menu. Choose the XML editor to edit the file. Browse the following line and remove it from the csproj file:

<Import Project="$(SolutionDir)\.nuget\nuget.targets" /> 

We are not there yet. There is one other change that is done to your projects: an extra property is added called ‘RestorePackages’. So we have to remove the following line from all csproj files:


Remark: Do all these changes in one run. Otherwise Visual Studio will re-add all this information once you reload the project file.


jkappers said...

Thanks for posting this! Now, I can have successful TFS build again.

Anonymous said...

Thanks for the tip. I missed the last step which led to many frustrating edits of the project files over and over again!

Wal said...

thanks very much. i decided to check my binaries into mercurial as it makes switching between different branches/versions easier later on and its one less dependency on a third party site.

Anonymous said...

Even simpler... Uninstall the damn NuGet package... it is not worth the pain