Try following below steps to fix that:
- Close Visual Studio
- Manually delete the local “packages” folder
- Reopen the solution, and rebuild. (Nuget should restore the
packages)
Source Link: Missing Nuget Packages on TFS Build Server
Or run the update-package -reinstall
command in NuGet Package Management Console to reinstall all referenced packages.
If that still not work, just try this:
Right click on .csproj
and open it in notepad or any editor and delete the following
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
Then build your solution and it should work.
And this thread for your reference: NuGet not restoring packages on build