«

Dec 11

Tell both NuGet and TFS to ignore the packages folder

Here’s the deal: We have to tell both NuGet and TFS to ignore the packages, because NuGet is trying to do source-control related stuff that it absolutely shouldn’t be doing (bad form, Microsoft!). So you have to do two things.

First, add a file named .tfignore to the solution folder (note the lack of s after the tf). It’s contents should be as follows:

The first three lines tell TFS to ignore your packages folder, the other lines are to exclude other special folders. You need to explicitly include repositories.config as it’s part of the NuGet stuff I outline below. (Double negative in exclude list above.)

OK, so now thanks to our .tfignore file, TFS is ignoring your packages and other special folders. Everything is fine, right? WRONG, because NuGet is mucking around with your source control and adding the packages to your pending changes. So now let’s tell NuGet to stop doing this.

  1. Create a physical folder called “.nuget” {tip in Windows Explorer type “.nuget.” as folder name to create it}.
  2. Add a virtual folder called “.nuget” in the root of your solution folder.
  3. Now, create a file called “NuGet.config”, in the physical folder then add it to the virtual folder.
    It’s contents should look like this:

And now your packages should stay out of source control. Just remember to add the “nuget.config”, “nuget.targets” and “.tfingore” files to source control so they never get lost.

1. Add the folder using Source Control Explorer; right-click the solution->Add folder->.nuget
2. The nuget.config file MUST go in the .nuget folder. Even if you already have a nuget.config file in the root of your solution folder (because, say, your company has an internal nuget feed). Yes, that means you’ll have two nuget.config files, one in the .nuget folder and one in the solution root. My testing indicates that’s the way it has to be. Additionally, if you do have a custom feed, ensure that you have both the custom feed and nuget.org as keys in the Nuget.config file, or sometimes TFS will randomly decide it can’t restore the packages.

Here’s some documentation for you: http://msdn.microsoft.com/library/vstudio/ms245454(v=vs.110).aspx#tfignore

880 total views, 3 views today

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">