Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After clone of web site project nuget restores packages but references are not found VS 2015

We have moved a legacy web site to git in TFS, and anytime the project is cloned nugget restores the packages per the package.config, and adds them to the packages folder. The subsequent build fails due to not being able to find the assemblies added through the nuget restore.

If you do a update-package -reinstall and the project builds successfully. Is this expected behavior or do I have a setup issue? The previous repo had the packages being checked in to eliminate this issue but I'd like to avoid that.

like image 761
sully77 Avatar asked Apr 03 '17 20:04

sully77


1 Answers

Is this expected behavior or do I have a setup issue?

Yes, this is expected behavior for NuGet, so do not worry that it is a setup problem.

NuGet Restore only restores files in the packages directory (\packages folder ), but does not restore files inside your project or otherwise modify your project. For example, if a package has added some reference DLLs or other files in your project, if you delete any of these files, they will not be re-added when restoring this package. This may cause the your project to not be able to find the missing dependencies when building.

Besides, the expected result is that the references should be used normally without broken after restore packages. In this case, we will not need to spend extra time using update-package -reinstall command line to uninstall and reinstall packages.

So use the "Update-Package -reinstall" command to force reinstall the package references and content files into project in order to resolve those references that were broken after packages restore.

like image 155
Leo Liu-MSFT Avatar answered Sep 28 '22 06:09

Leo Liu-MSFT