Nuget Like a Boss
Part 1: Don't check in Packages
After suffering like many with so many Package Restore woes in my projects I decided to make notes on the best way to deal with Nuget packages.
Ignore the packages folder
Not doing this means you check in the packages which are huge. This is annoying and kind of defeats the purpose of Nuget. When you ignore (and therefore don't check in) your packages folder, anyone getting your source code can run package restore on the solution and Nuget will download the packages automatically.
First, add a file named .tfignore. This may require some Command prompt renaming as some set ups don't like files beginning with a dot. When you get past this annoyance, open the file in notepad and enter the following:
That tells TFS to ignore the packages folder. For some bizarre reason, this doesn't include the respositories.config file. You'll need to add a second line as follows:
You'd think this would be it, but you may notice that your packages folder is already in your Pending changes. To get around this, create a folder called .nuget (command prompt trickery may be required) and in there create a file called NuGet.config. It must go in this folder, even if you have another NuGet.config at solution level. Enter the following text:
<?xml version="1.0" encoding="utf-8"?> <configuration> <solution> <add key="disableSourceControlIntegration" value="true" /> </solution> </configuration>
This should ensure that your packages stay out of source control.
Finally ensure that .tfignore and NuGet.config are added to source control so that these settings should apply for anyone using the project.
Be aware that the .tfignore file may not work if someone has already checked in the packages folder. Delete this from source control and you should be good.