How to enable nugets package restore in Visual Studio 2015?

前端 未结 7 636
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 18:51

How do I enable the nuget package restore feature in Visual Studio 2015?

The feature is just missing in my context menu (Yes - I\'ve double checked that I try it on

7条回答
  •  天涯浪人
    2020-12-07 19:19

    As it turns out, the real solution is to migrate to Automatic Package Restore. We experienced issues with NuGet after upgrading to VS 2015 after working in 2013 for a while. Turns out the old way of doing NuGet completely hoses the new way of doing it.

    The solution is simple, though tedious. Apparently the NuGet.targets file signals VS to use the old NuGet way of doing things, and it's absence means that you are now using "Automatic Package Restore". You can migrate to Automatic Package Restore by following these steps:

    1. Delete .nuget/NuGet.exe
    2. Delete .nuget/NuGet.targets
    3. For each project:
      1. Unload the project
      2. Right click -> Edit the project
      3. Delete all references to the NuGet.targets file, i.e. the following:
    true  
    ...
      
    ...
      
        
            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}.
        
        
    
    

    There is also a powershell script that will perform the migration for you, if you are feeling bold. You can find it on github.

提交回复
热议问题