Reputation: 412
We are migrating all our projects to use nuget references. Together with a source control (in our case DevOps and Git) I noticed a strange behavior of the nuget package manager.
When we check in projects with nuget references, other coworkers (who checkout this project) get reference errors within the project. I analysed it an noticed that, in the working version of the branch, the dlls of the nugetpackages are not included. The package.config looks fine to me.
My question to this is: do we need to checkin packages dlls from nuget to the source control? In my understanding nuget should check if the packages/assemblies are downloaded and if not, should re-download them.
In visualstudio under nuget package manager -> "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" both options are checked (on all clients).
I also checked in a project only with the packages.config - without the packages folder. But the references are not recoginised as before / an autorestore did not happen on the load / build of the project.
Upvotes: 0
Views: 1379
Reputation: 412
I solved my erros my switching from packages.config to packagereferences. In the build / rebuild event all DLLs are now pulled from nuget sources, if they are not existing.
See this blogpost for reference https://devblogs.microsoft.com/nuget/migrate-packages-config-to-package-reference/
Upvotes: 1
Reputation: 36081
No, you don't need to include the dlls for the packages in source control. The packages.config is all you need as this contains enough information to fetch all of the required libraries that are required to run your code.
In Devops you need to add a nuget restore task to your build. This will pull down all of the required dlls.
Using a package manager like nuget (or npm etc) allows you to keep only your code in source control. It also prevents cases of "it works on my machine" where Developer1 has a specific locally referenced dll but Developer2 doesn't.
If reference errors are occurring for individual developers it could be that someone has checked in a reference to a local file rather than a nuget package.
Upvotes: 0