Unable to Install Any Package in Visual Studio 2015

后端 未结 19 2312
太阳男子
太阳男子 2020-12-07 13:32

I\'ve tried every package I could possibly find and none of them will install in my project. I\'ve installed every update listed in the Extensions and Updates list that wer

相关标签:
19条回答
  • 2020-12-07 14:03

    In my case, nothing of the above helped. The root cause of the problem in my case was, that I uninstalled the package before and did not check in the change into source control (TFS in my case). After checking in the change (=the deletion of file in the packages folder), I could reinstall the package.

    0 讨论(0)
  • 2020-12-07 14:05

    tl;dr - Delete this:

    %AppData%/Nuget/Nuget.config
    

    Warning: If you had custom NuGet sources, this will remove them, and you'll have to re-add them.


    Longer version:

    You might have corrupted your NuGet config. Oh no :(

    Nuget.config is a file used to keep track of all of the places that NuGet pulls from, as well as configuring other things. More likely than not, this xml file got broken somehow.

    • Go to this path: C:\Users\{{username}}\AppData\Roaming\
    • Delete Nuget.config
    • Restart VS for good measure

    For reference: in the good days of 2017, your file should look something like this

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageRestore>
        <add key="enabled" value="True" />
        <add key="automatic" value="True" />
      </packageRestore>
      <activePackageSource>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
      </activePackageSource>
      <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
        <add key="nuget.org" value="https://www.nuget.org/api/v2/" />
        <!-- Others -->
      </packageSources>
      <packageSourceCredentials>
        <!-- secret stuff -->
      </packageSourceCredentials>
    </configuration>
    
    0 讨论(0)
  • 2020-12-07 14:06

    I found a solution for this in my case, try to update the NuGet Package Manager.

    To do this:

    1. From VS, go to Tools -> Extensions and Updates
    2. Open the Updates menu option at the left, then select Visual Studio Gallery.
    3. If there is an update for Nuget Package Installer, it should show in the list to the right. Click Update
    4. Restart Visual Studio

    This let me install packages without problem again.

    Hope this helps!

    0 讨论(0)
  • 2020-12-07 14:07

    In my case, there was an empty packages.config file in the soultion directory, after deleting this, update succeeded

    0 讨论(0)
  • 2020-12-07 14:09

    Closing and re-opening VS2015 resolves the issue.

    It seems that in some cases, simply reloading the affected project will work.

    0 讨论(0)
  • 2020-12-07 14:13

    You need to Clear All NuGet Caches; for this you need go to Options and click on it like this:

    0 讨论(0)
提交回复
热议问题