Search code examples
c#.netnugetpackages.config

NuGet, Packages.config, .csproj and references


I have a question so that I can better understand NuGet packages, packages.config and the .csproj file.

It is my understanding that the setting in the NuGet Package Manager >> General for default package management format determines if your project uses packages.config or the .csproj file for resolving and restoring packages. In my project we have selected Packages.config.

No problem it compiles and runs. So I decided to test if it would run without the reference for a dll in the .csproj file, as it is my understanding it does not use or need this. This is an incorrect assumption as though the package is in the packages.config file, when I removed the reference in the .csproj file there was an error in my project and the project would not compile.

I also noticed that if the dll is not in the references in the Solution Explorer that it fails to compile as well I( I assume these are the .csproj references).

So I am not clear on the role of the .csproj file for a Packages.config Management format for NuGet packages and the references in Solution Explorer.


Solution

  • The difference is on how you manage your NuGet references.

    Before VS2017 the information what NuGet packages to be used during assembly was stored in files packages.config.

    Since VS2017 there is a new option called package references which stores this information in the project (.csproj) file.

    https://devblogs.microsoft.com/nuget/migrate-packages-config-to-package-reference/