Multiperson team using NuGet and source control
Don't check the packages folder in.
Add the following prebuild event to your project:
$(SolutionDir)build\nuget install $(ProjectDir)packages.config -source \\server\path\NuGetPackages -o $(SolutionDir)packages
Omit -source parameter
if not using custom packages.
nuget.exe is checked into $(SolutionDir)build\nuget
.
I always check in just the packages.config folder and use a Rake task that the developer (and build server) can use to update packages locally.
The task looks like:
def nuget_for_project(project_dir)
sh "tools\\NuGet.exe " +
"i Source\\#{project_dir}\\packages.config " +
"-o Source\\Packages"
end
namespace :nuget do
desc "nuget for servicebus"
task "ServiceBus" do
nuget_for_project "SampleProject.ServiceBus"
end
desc "nuget for web"
task "Web" do
nuget_for_project "SampleProject.Web"
end
desc "nuget for all"
task "all" => ["nuget:ServiceBus", "nuget:Web"]
end
Note that the above script uses a local version of NuGet.exe that is in a tools folder checked into source control.
You could write this for MSBuild or NAnt instead.
I wrote a longer blog post on this a while back that may be helpful.
I have this issue also. I like the idea of NuGet restore, but I don't feel I should need it. I want my JR developers to be able to check out a solution and have everything they need.
So I put my packages folder under source control.
My solution to enabling NuGet in this circumstance was to take note of this from above:
"I assume this is because the repositories.config file is now under source control (so it is read only until manually checked out)."
I opened the repositories.config file and added a blank line. Then I added the NuGet packages I need. Problem solved.
Edit 2014/03/31: The manual MSBuild-based package restore enablement is no longer needed, see also http://xavierdecoster.com/migrate-away-from-msbuild-based-nuget-package-restore.
Edit 2012/02/07: This is now a built-in feature of the NuGet vsix, called Enable Package Restore.
Obsolete Alternative
There is a NuGet package for that, it's called NuGetPowerTools. It adds two new commands to the NuGet Package Manager Console in Visual Studio, amongst which Enable-PackageRestore is the interesting one for you.
It will add a .nuget folder which contains nuget.exe, nuget.settings.targets and nuget.targets. When you run enable package restore, it will enumerate all projects in your solution and add an import nuget.targets statement in the project files (which are actually msbuild files themselves).
Whenever you build a project or the entire solution, nuget will fetch all packages for that project/solution, as defined in the packages.config file. This happens in a pre-build step.
So, in short:
- do not check-in packages
- do check-in the config files (repositories.config and packages.config files)
- use Enable Package Restore
- check-in the .nuget folder
Whenever someone gets the sources, whether that's another developer in the team or a build agent, the msbuild process will be instructed to fetch any required packages in a pre-build step.
Also, when the packages are not committed into TFS Source Control, you won't hit the read-only flag issues, or merge conflicts with binary files.
If you want, you can also check-out the underlaying reasoning for this approach on my blog.