NuGet Package Restore Error–NuGet package(s) are missing.

Recently I had a bizarre error and this might help someone else who stumbled on this error.

image

Scenario:

I had the solution and source code underneath it and worked on one machine and then moved (Copied) to another machine on another folder. Because it is also one of the scenarios I had to support where the code could be just file copied from machine to machine and another developer could then just RightMouse and “Build” it.

This is in addition to the fact that one could get it from Version Control and there were cases that the solution and SRC code would have also been just File Copied.

So when I moved over the entire solution and code underneath it to another machine by file copy and brought it up in VS and then hit Right Mouse and Rebuild, and I got the above error.

I went through the link in the error message, but it did not help. It was talking about missing NuGet packages. However the Nuget packages are still there.

So after doing some more digging, I went into the Project file at the line where the error was pointing me to.

image

So as I mentioned this is a “File Copy” move and the paths to the nugget packages are referring to the older locations. Once I edited the two lines (in this case 447 and 448 above) to refer to the new locations where I had moved the project, then the Build error went away.

This is probably an edge case, and hopefully helps someone. It is quite likely there are other ways to avoid this error also, and I am not aware of it.