问题
I've had a Visual Studio solution running successfully on my machine but when I've committed the changes to BitBucket and another user has pulled down the project and built it on either Visual Studio or TeamCity we've received errors such as:
error CS0234: The type or namespace name 'Entity' does not exist in the namespace
'System.Data' (are you missing an assembly reference?)
When I've looked at the project, I can see that each NuGet package folder is present but the DLLs are missing. This itself is an easy fix; I just delete the offending package and on the next build NuGet restores the package and the DLLs are now present.
What I don't understand is why NuGet is not getting the DLLs on the first attempt?
回答1:
It took me a while to work out what was happening, but the problem wasn't NuGet, it was the setup of source code control.
I had not added the packages
folder to the ignore list for Mercurial. By default, it was uploading the NuGet packages to BitBucket but ignoring the DLLs. When another user downloaded the project it pulled down the packages and Visual Studio or TeamCity saw the package folders and assumed the package was already downloaded. Addeing the packages folder to the .hgignore file will stop this happening in future.
来源:https://stackoverflow.com/questions/44829117/nuget-restoring-packages-but-missing-dlls