I know I should be using nuget more but at this point I don't completely understand the nuances so I still tend to either get source and build the project, then reference the project, or I create my own "dlls" folder and hand copy the dll's in.
As part of my learning process, I'm trying to understand what is critical and what is not when using nuget. For example, I've done install-package restsharp and now when I check into source control, I get files like "packages/RestSharp.103.4/lib/net4/RestSharp.xml". I'm assuming that nuget will help me with upgrading and such and it needs to have certain meta data type files.
My question is: Should I be ignoring any or all files in the "packages" directory? If so, what and why.
Thanks
There are two workflows for handling this situation. The original workflow was to commit all files (you don't need to ignore any) in the packages directory so that other developers on your team would have the packages to build the project.
The newer workflow, available since NuGet 1.6, is to enable NuGet's package restore feature for a solution. This will cause any missing package files to be automatically downloaded when building the project, but now you no longer have to commit large binary files to your version control. As of NuGet 2.0, it is now required to have each developer on your team enable NuGet's package restore permission inside the Visual Studio options.
In Visual Studio, under Project, there is a menu item called Enable NuGet Package Restore
. This is available when you have a project open and you are using Web Application Projects (restore does not work with Web Site Projects). Select that and enable package restore. Then, you do not need to commit the Packages directory to source control anywhere.
NuGet's documentation has much more information on package restore.
If you want to possibly mimic package restore manually, you will need something that parses the packages.config
file and then executes the NuGet Commandline Bootstrapper (nuget.exe
) to install those packages. Luckily the bootstrapper takes a packages.config as a parameter. Using the following steps should restore your packages:
packages
folder off of the directory where the solution is.From the packages directory run the following from the command line:
nuget.exe install [path to packages.config]
This can all be done from within a batch file or however you'd like to automate it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With