77

NuGet newbie question-
I saw repositories.config being added in NuGet packages folder.
Can anyone please guide me what is the purpose of this file?

Thank you!

gturri
  • 13,807
  • 9
  • 40
  • 57
inutan
  • 10,558
  • 27
  • 84
  • 126

3 Answers3

65

It's a file that's mostly a NuGet implementation detail, and should not be dealt with directly (it may go away or change in the future).

But for reference, it contains a list of paths that point to all the packages.config in the solution. Typically there is one per project that uses NuGet.

David Ebbo
  • 42,443
  • 8
  • 103
  • 117
  • 44
    Should it be included in source control? – Colonel Panic Jun 26 '12 at 14:31
  • 44
    @MattHickford If you use the Package Restore workflow, you can completely omit the Packages folder from source control (including this file). – David Ebbo Jun 26 '12 at 17:41
  • 2
    One more thing. If you use CI TeamCity >= 7.0 there is a build step Nuget Install. And that step requires that file. At least in 7.0.3. We've had to add repositories.config to git. Be careful. – Sergio Rykov Aug 02 '12 at 19:04
  • 1
    I had added some projects to a solution that I later removed from the solution, and it didn't clean up the references in my repositories.config file. Manually editing this file seemed like the right thing to do in this case. – Funka Jan 24 '13 at 00:32
  • 3
    I keep deleting the packages folder in TFS (local workspace), committing that deletion, and I always have `\*\packages` ignored in `.tfignore`, but the damn `packages\repositories.config` keeps getting added back to TFS. There are several unanswered questions about this on the net. Can you clarify the expected bahavior here? Thanks! – Jason Kleban Aug 22 '14 at 14:15
  • @uosɐſ NuGet seems to be adding it to source control on it's own, see this answer for a solution to the repositories.config issue: http://stackoverflow.com/a/28682504 – Christian Fredh Sep 09 '15 at 08:11
30

David Ebbo's answer is from 2011, and the official advice keeps changing between versions.

Here's where we stand in 2015, for NuGet 2.7+ with the 'Automatic Package Restore' (recommended) workflow

I'm paraphrasing, but basically the advice is:

Remove packages/repositories.config from source control. We'll re-generate it anyway.

...unless it somehow breaks on your machine. Then do add it to source control.

This hint comes from the section on ignoring files in git:

# Ignore NuGet Packages
*.nupkg
# Ignore the packages folder
**/packages/*

And the important part:

[...]

# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
Community
  • 1
  • 1
Cristian Diaconescu
  • 34,633
  • 32
  • 143
  • 233
  • 2
    Every time I do a build in VS, repositories.config is automatically added to source control. How can I prevent this? The .tfignore file does not seem to have any effect on this nor setting disableSourceControlIntegration to true. – Timothy Schoonover Sep 01 '15 at 21:57
  • @odysseus.section9 See http://stackoverflow.com/questions/24143925/get-tfs-to-ignore-my-packages-folder – NathanAldenSr Mar 10 '16 at 15:04
9

You need to include the repositories.config file in your source repository if you are following the Automatic Package Restore work flow.

Have a look on http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages where it specifically mentions this point.

Mickey Puri
  • 835
  • 9
  • 18
  • 3
    Yep just a little bit confusing because it looks like NuGet has evolved somewhat since the accepted answer. @David Ebbo syays you can completely omit the packages folder (including the repositories.config file) but your link specifically states: Be sure to check in your _repositories.config_ file in a bright yellow box. It then goes onto mention other VCS systems. So I wonder if the accepted answer was referring to a pure "Package Restore Workflow" within TFS or is now just an outdated response. – rism Mar 05 '14 at 22:11
  • 11
    The above link is about the MSBuild-based package restore, not the [Automatic package restore](http://docs.nuget.org/docs/reference/package-restore) which does not mention repositories.config – Max Toro Mar 29 '14 at 00:56
  • Alas, the page you linked now does a 301 redirect to /consume/package-restore/msbuild-integrated – Chris F Carroll Mar 30 '15 at 08:50
  • Today, for the 'automatic package restore' workflow, not the MSBuild, with Nuget 2.8.6 and VS 2013 using TFS, I find I need ./packages/repositories.config in source control (but not any of the packages themselves). I also need ./.nuget/nuget.config in source control (and nuget.targets and nuget.exe must be expunged from TFS and workspace) and every csproj file must have all traces of the nuget target and package restore expunged. The need for repositories.config was undocumented the last time I checked nuget webpage. – subsci May 06 '15 at 22:12