NuGet-Repositories.config

新手问题
我看到 repositories.config被添加到 NuGet 包文件夹中。
谁能告诉我这个文件的目的是什么?

谢谢!

28242 次浏览

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.

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.

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