简体   繁体   中英

How to upgrade NuGet with Visual Studio 2017?

I'm getting a build error that I need to upgrade NuGet:

The 'Microsoft.NETCore.Platforms 1.1.0' package requires NuGet client version '2.12' or above, but the current NuGet version is '2.8.60318.667'.

From what I've found online, within VS, I'm supposed to go to Tools > Extensions and Updates. And I'm supposed to see an option to upgrade NuGet within the Updates tab. As you can see, that option isn't there:

在此处输入图片说明

My solution has a .nuget folder, and it has NuGet.exe in it, which has a version of 2.8.x. How can I upgrade to 2.12?

How to Upgrade NuGet with Visual Studio 2017

That because you have a .nuget folder at solution level, that folder contains an old (2.8.x) nuget.exe file. A lot of packages might need new version of that file. You should update it:

  1. Open this link: https://www.nuget.org/downloads , switch to the Windows x86 Commandline tab, download 3.3 or above.
  2. Download latest version of nuget.exe
  3. Replace your .nuget/nuget.exe with this new version.

And try again.

Besides, your solution is using an old nuget restore method that has been deprecated. Automatic Package Restore is the NuGet team's recommended approach to Package Restore within Visual Studio, and it was introduced in NuGet 2.7. Beginning with NuGet 2.7, the NuGet Visual Studio extension integrates into Visual Studio's build events and restores missing packages when a build begins.

See this thread NuGet auto package restore does not work with MSBuild and Nuget: Switching from "Enable Package Restore" to "Automatic Package Restore" for some more details.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM