NuGet Package Restore Not Working

后端 未结 20 1995
情书的邮戳
情书的邮戳 2020-12-02 04:06

I checked in a project on one computer, checked out on another, and find that the binaries installed by NuGet are missing. I could check them in to source control as well,

相关标签:
20条回答
  • 2020-12-02 05:04

    For others who stumble onto this post, read this.

    NuGet 2.7+ introduced us to Automatic Package Restore. This is considered to be a much better approach for most applications as it does not tamper with the MSBuild process. Less headaches.

    Some links to get you started:

    • The right way to restore NuGet packages
    • Migrate away from MSBuild-based NuGet package restore
    • Migrating MSBuild-Integrated solutions to use Automatic Package Restore
    0 讨论(0)
  • 2020-12-02 05:04

    Just for others that might run into this problem, I was able to resolve the issue by closing Visual Studio and reopening the project. When the project was loaded the packages were restored during the initialization phase.

    0 讨论(0)
  • 2020-12-02 05:04

    I had NuGet packages breaking after I did a System Restore on my system, backing it up about two days. (The NuGet packages had been installed in the meantime.) To fix it, I had to go to the .nuget\packages folder in my user profile, find the packages, and delete them. Only then would Visual Studio pull the packages down fresh and properly add them as references.

    0 讨论(0)
  • 2020-12-02 05:05

    VS 2017

    Tools>NuGet Package Manager>Package Manager Settings>General Click on "Clear All NuGet Cache(s)"

    0 讨论(0)
  • 2020-12-02 05:05

    The best workaround that I found creating a new Project from scratch, then import all the source files with the code. My project was not so complicated so I had no problem from there.

    0 讨论(0)
  • 2020-12-02 05:05

    vs2015 no enable nuget restore problem. My solution:

    1. add folder .nuget, add file NuGet.Config and NuGet.targets in Directory .nuget

    2. each project file add: build

      <RestorePackages>true</RestorePackages>
    
      <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
      <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
        <PropertyGroup>
          <ErrorText>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}.</ErrorText>
        </PropertyGroup>
        <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
      </Target>
    
    0 讨论(0)
提交回复
热议问题