Reputation: 6963
A Project with NuGet packages won't compile, the error is: "The project references NuGet package(s) that are missing on this computer, Enable NuGet Package Restore to download them."
Here's the Nuget Restore Option in Visual Studio:
If I look at the reference in the project, I see more than just the Nuget Packages missing!
If I attempt a restore at Solution layer...
If I attempt the Package Manager Console option of:
update-package -reinstall -projectname myProjectName
The output window successfully uninstalls and then reinstalls all the packages!
None of the references are good they are still all Yellow-Flagged as in the image above.
The Packages.Config File looks like this:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.4.0" targetFramework="net45" />
<package id="Selenium.Support" version="2.53.1" targetFramework="net45" />
<package id="Selenium.WebDriver" version="2.53.1" targetFramework="net45" />
<package id="Selenium.WebDriver.ChromeDriver" version="2.23.0.1" targetFramework="net45" />
</packages>
When did this start failing?
Today I had to create a solution that included all the projects in a folder (with just one of them being the one shown in example above). I named it the AllSolutions.sln. When I added all of those projects, I got Nuget errors saying pacakges were missing. I attempted, with success, restoring all NUGET pkgs. using the solution level "Restore all Packages". The compile then worked for AllSolutions.sln.
I then opened a single one of the solutions from my C:drive (mapped to TFS properly). This is when the problem shown above surfaced.
Upvotes: 0
Views: 889
Reputation: 6963
Compile is working now, here was the solution:
I restarted Visual Studio, connected to TFS and clicked on the same solution as before. But this time, the project had new items in it as follows:
The .nuget folder was the original folder which apparently disappeared when I included this project in the AllSolutions.sln. (Note I did not manually delete this folder). The second is an internal project we have that just specifies what packages we use in the packages.config file.
I have no idea why reconnecting to TFS, opening the Solution file from the Team Explorer menu, (after a VS reboot) fixed this issue. But maybe this will help someone else.
And as proof, the original "Yellow Tagged" references shown above now look like this:
Root Cause:
I believe that including the same project in multiple projects has side effects related to Nuget restrore. The reason is that the .nuget folder is removed as shown in this post.
What was learned:
Migration of Nuget scripts was not necessary.
If your project is having this problem it can be related to a missing .nuget folder! Good luck in getting it restored.
Upvotes: 1