Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding nuget packages in TFS - does packages.config need to be Checked In?

I am wondering if anyone is aware of how to properly include an Nuget package in my application. Installing it - adds the references automatically in Solution Explorer. In addition it create/display a file called package.config - and it looks like it wants to be added in my project. It is shown in Solution Explorer but appears in my root folder with a little + sign next to it - and allows me to Check In Pending Changes / add it. Am I supposed to add it to my project?

enter image description here

I basically don't want to screw up anything.

like image 595
BobSki Avatar asked Mar 15 '17 16:03

BobSki


People also ask

Should you check in NuGet packages?

NuGet no longer creates a packages folder inside your source structure. Instead there is one in your user directory ( %USERPROFILE%\. nuget\packages on Windows, to be specific) where it puts all packages it downloads, and projects just reference these. So the simple answer these days is no, you shouldn't.

What about NuGet packages and packages config?

The packages. config file is used in some project types to maintain the list of packages referenced by the project. This allows NuGet to easily restore the project's dependencies when the project is to be transported to a different machine, such as a build server, without all those packages.

Why do we need NuGet config?

Multiple NuGet. Config files allow you to store settings in different locations so that they apply to a single project, a group of projects, or all projects.


2 Answers

Yes the packages.config file is required. This file holds the packages you reference and the versions youre using. NuGet uses this file to restore your packages in a TFS build of on the machine of another developer.

Here is some more information on NuGet dependency resolution

Note that you should not checkin the packages folder in your solution folder. NuGet will restore packages to this folder using the packages.config file

UPDATE: the <PackageReference> format was introduced a while back. It can be used with both the old and new .csproj formats. One of the benifits is that the paths to the packages are no longer in your project file so you will get a lot less updates/merge conflicts when updating NuGet packages. See this page for more information: https://learn.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files

like image 81
Sander Aernouts Avatar answered Oct 16 '22 19:10

Sander Aernouts


Yes, it's usually checked in as part of your solution. Source control and all that.

like image 1
Jim Roth Avatar answered Oct 16 '22 20:10

Jim Roth