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?
I basically don't want to screw up anything.
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.
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.
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.
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
Yes, it's usually checked in as part of your solution. Source control and all that.
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