2

The same symptom as Nuget Packages are there but missing References but much simpler use case to duplicate:

  • User A checkin his/her code into TFS
  • User B (or C, D, etc) get the solution from TFS, for the first time, or into a brand new place.

Result: all References dll maintained by Nuget showing broken yellow triangle, even after the "Clear All NuGet Cache" and "Update-Package -reinstall" hack recommended by that thread. Closing & reopening VS & solution won't work, despite that the dll are exactly there, as hinted, after Update-Package -reinstall.

This is VS2017 version 15.3.5.

UPDATE:

Turns out what "available" was an ".xml" file, whose extension was not shown normally in File Explorer. I.e., the ".dll" file is missing and is not restored by Update-Package -reinstall.

UPDATE2:

The Update-Package -reinstall is not working because it failed to add reference (Reference unavailable). Here is the full log: Update: removed after it is solved, see the history, or check out from https://pastebin.com/1e5axkTm.

As I look at the log, I see,

Package 'NUnit 3.6.1' does not exist in project 'MyProj'
Package 'NUnit 3.6.1' already exists in folder '\Path\To\MySolution\packages'
...
Update-Package : Failed to add reference to 'nunit.framework'.
  Reference unavailable.

My interpretation is, because the nunit.framework DLL in not in TFS, thus it is not available locally for User B (or C, D, etc) who gets the solution from TFS, but Update-Package -reinstall does not notice and cannot fix the problem. Hence causing more problem down the road -- failed to add reference (Reference unavailable).

UPDATE3:

Thanks to @LeoLiu-MSFT & @starianchen-MSFT's help, not including the package folder in Source Control solved the above problem. The "Update-Package -reinstall" don't have any errors now (in case you need to double-check, https://pastebin.com/e8TpXg2D)

FINAL UPDATE:

Yes, @LeoLiu-MSFT & @starianchen-MSFT, not including the package folder in Source Control is the key! please answer so that I can accept.

The following are caused by an entirely different issue -- All MS VS References broken after project moved.

However, even after above, and use "NuGet Package Restore" to download them, I'm still getting the following:

Error This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Selenium.WebDriver.ChromeDriver.2.28.0\build\Selenium.WebDriver.ChromeDriver.targets.

  • I've checked the page of http://go.microsoft.com/fwlink/?LinkID=322105, the "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" have already been checked.
  • I've removed the packages\Selenium.WebDriver.ChromeDriver.2.28.0 folder several times, and did "NuGet Package Restore" several times as well, but the problem remains.

What's the proper fix?

xpt
  • 20,363
  • 37
  • 127
  • 216
  • What's the detail version of your VS2017? What's the result after rebuild the solution? What's the type of your project? Provide the detail steps to reproduce this issue. On the other hand, I am not clear about your update, provide the sample to explain it. – starian chen-MSFT Dec 18 '17 at 03:13
  • @xpt, how about this issue now? Have you resolved this issue? If yes, could you please share you solution here? If not, could you paste the log after using `Update-Package -reinstall` and what is the prompting information when you move your mouse over to the yellow triangle? – Leo Liu Dec 21 '17 at 02:13
  • @starianchen-MSFT, rebuild will get compile errors, as the References are missing. @Leo, the `Update-Package -reinstall` will not install the missing dlls, as explained in OP. That being said, after a mad chase of wild goose, I got one system working and I don't know exactly what make it works, but definitely not `Update-Package -reinstall` alone. I'll find a system that is still not working and post back & update OP. – xpt Dec 21 '17 at 14:57
  • 1
    Found it, `Update-Package -reinstall` not working because it _`Failed to add reference`_. See updated OP. – xpt Dec 21 '17 at 16:03
  • Do you include package folder in Source Control? Can you share a simple sample on the Github? – starian chen-MSFT Dec 22 '17 at 01:49
  • @xpt, It seems you add the nuget package `NUnit 3.6.1` or `nunit.framework` DLL into the source control. If yes, please remove it from source control. You just need to check the packages.config to the source control, when other User `B` who gets the solution from TFS, then use the command line `Update-Package -reinstall`, VS/NuGet will restore the packages first, then re-install the dll to the project. – Leo Liu Dec 22 '17 at 02:06
  • Thanks @LeoLiu-MSFT & @starianchen-MSFT, that seems to be the cause, _including the package folder in Source Control_. However, that's not my decision but TFS's, and NuGet's. I.e., When adding files to Source Control, TFS used to be smart enough not to include many unnecessary files, but not the `package` folder. Moreover, having deleted it from TFS, and redo a `Update-Package -reinstall`, NuGet puts the `package` folder and all folders and files beneath it back into TFS _again_. – xpt Dec 29 '17 at 16:00
  • @LeoLiu-MSFT & @ starianchen-MSFT, sorry for the delay, OP updated. – xpt Jan 02 '18 at 15:59
  • @xpt, It does not matter. Thanks for your update information. I have post an answer, you can accept it. – Leo Liu Jan 03 '18 at 01:43

1 Answers1

2

Broken Nuget Packages References out of the box

According to your error log in the UPDATE2:

Package 'NUnit 3.6.1' does not exist in project 'MyProj'
Package 'NUnit 3.6.1' already exists in folder '\Path\To\MySolution\packages'

It seems that you added the packages folder in source control.

To resolve this issue, you should remove that packages folder from source control. You just need to check the packages.config (or project.json) to the source control, when other User B who gets the solution from TFS, then use the command line Update-Package -reinstall, VS/NuGet will restore the packages first, then re-install the dll to the project.

xpt
  • 20,363
  • 37
  • 127
  • 216
Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • Thanks, Leo. I just made an update, is it what you were trying to say? (in Unix "`/`" symbolizes _path_) – xpt Jan 03 '18 at 01:47
  • @xpt, Yes, Thanks for your update :). I am not familiar with Unix, so that I did not notice this difference. – Leo Liu Jan 03 '18 at 01:55