KidBatman
KidBatman

Reputation: 595

Enabling Nuget Package Restore and Source Control

I am trying to move my solution to utilize NuGet Package Restore so that I can keep the packages folder out of source control. I have some confusion as to how to properly implement it however.

  1. I currently have the packages folder in TFS, should I delete it before committing the changes for NuGet Package Restore?
  2. Do I need to commit the .nuget folder to source control? This article is telling me to remove .NuGet.exe and NuGet.targets as well.
  3. Will using NuGet Package Restore break build in TFS? (say for gated check-ins)

Upvotes: 2

Views: 359

Answers (2)

Daniel Mann
Daniel Mann

Reputation: 58980

  1. Yes.
  2. The better option is to use the Package Restore Migration script. I've used it several times and it works beautifully. It will remove NuGet.exe, NuGet.targets, and also (very importantly) clean up your project files to remove references to the NuGet.targets file. If you just delete NuGet.targets, it will break your builds.
  3. NuGet package restore shouldn't break any builds if you follow the steps outlined in the article you linked very closely. Of course, your build server will need access to the internet so it can get to nuget.org. If your build server is locked down and has no internet access, package restore will definitely not work.

Make sure that you close down Visual Studio before running the package restore migration script... I've found that if you run the script with the solution open, it won't work properly.

If you're using Git, add the packages folder to your .gitignore. If you're using TFVC, make sure that your NuGet.config file has the disableSourceControlIntegration key set to true.

Upvotes: 2

From Visual Studio 2013 update 3 Nuget package restore is the default and does not need enabled.

If you delete the /packages folder and check in it should just populate automatically with no additional work required.

Yes: Remove nuget.targets and .nuget folder.

Upvotes: 1

Related Questions