An error occurred while trying to restore packages. Please try again

前端 未结 10 1039
遇见更好的自我
遇见更好的自我 2020-12-16 09:45

I am trying to restore the missing nuget packages and it keeps giving me this Error:

An error occurred while trying to restore packages. Please try again.


        
相关标签:
10条回答
  • 2020-12-16 10:20

    Just in case it helps someone else, I had this issue in a .NET Standard project where I had defined the target frameworks incorrectly:

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <TargetFramework>netstandard1.3;netstandard2.0;net45</TargetFramework>
        </PropertyGroup>
        ...
    

    When it should have been the plural TargetFrameworks (not TargetFramework):

    <Project Sdk="Microsoft.NET.Sdk">
        <PropertyGroup>
            <TargetFrameworks>netstandard1.3;netstandard2.0;net45</TargetFrameworks>
        </PropertyGroup>
        ...
    

    0 讨论(0)
  • 2020-12-16 10:23

    (Definitely a beginner's answer here, but I'll leave it since I didn't find this anywhere else.) Make sure that nuget.org hasn't been unchecked from your package sources.

    Tools. Options. Nuget package manager. Package sources. Ensure "nuget.org" is checked.

    0 讨论(0)
  • 2020-12-16 10:25

    If you don't want the package, just double-click your packages.config, find the line which refers to the package you want to get rid of, and delete that line.

    Then, if you do want the package you could probably just redownload it using nuget and it'd probably resolve itself.

    0 讨论(0)
  • 2020-12-16 10:31

    I had a similar issue with the Microsoft.Bcl.Build.1.0.14 NuGet package. My solution to this was to

    1. Close Visual Studio
    2. Remove the package folder with Explorer (or better only move it to another location)
    3. Start Visual Studio
    4. Go to the NuGet package manager and click Restore
    0 讨论(0)
  • 2020-12-16 10:33
    1. Make sure you upgrade to the latest NuGet (http://docs.nuget.org/docs/start-here/installing-nuget).
    2. Make sure you're doing package restore "The Right Way" http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html

    That should resolve the issue.

    0 讨论(0)
  • 2020-12-16 10:33

    For me I cloned a solution (vs2015/NuGet3.4) that had a nuget dependency on a pre-release package that had been superceded. Nuget failed to restore the pre-release and wouldn't let me either uninstall or upgrade it. I frigged it by manually editting packages.config to target an older non-pre-release of the package, which I could then upgrade to the version I wanted. HTH

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