如何使用 Visual Studio 2017 升级 NuGet? [英] How to upgrade NuGet with Visual Studio 2017?

查看:62
本文介绍了如何使用 Visual Studio 2017 升级 NuGet?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到需要升级 NuGet 的构建错误:

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

Microsoft.NETCore.Platforms 1.1.0"包需要 NuGet 客户端版本 '2.12' 或更高版本,但当前的 NuGet 版本是'2.8.60318.667'.

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'.

根据我在网上找到的内容,在 VS 中,我应该转到工具">扩展和更新".我应该会在更新"选项卡中看到一个升级 NuGet 的选项.如您所见,该选项不存在:

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:

我的解决方案有一个 .nuget 文件夹,其中有 NuGet.exe,版本为 2.8.x.如何升级到 2.12?

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?

推荐答案

如何使用 Visual Studio 2017 升级 NuGet

How to Upgrade NuGet with Visual Studio 2017

因为您在解决方案级别有一个 .nuget 文件夹,所以该文件夹包含一个旧的 (2.8.x) nuget.exe 文件.许多软件包可能需要该文件的新版本.你应该更新它:

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. 打开此链接:https://www.nuget.org/downloads,切换到 Windows x86 Commandline 标签,下载 3.3 或更高版本.
  2. 下载最新版本的 nuget.exe
  3. 用这个新版本替换你的 .nuget/nuget.exe.
  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.

然后再试一次.

此外,您的解决方案正在使用已弃用的旧 nuget 还原方法.自动包还原是 NuGet 团队推荐的在 Visual Studio 中进行包还原的方法,它是在 NuGet 2.7 中引入的.从 NuGet 2.7 开始,NuGet Visual Studio 扩展集成到 Visual Studio 的构建事件中,并在构建开始时恢复丢失的包.

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.

请参阅此线程 NuGet 自动包还原不适用于MSBuildNuget:从启用包还原"切换到自动包还原",了解更多详细信息.

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.

希望这会有所帮助.

这篇关于如何使用 Visual Studio 2017 升级 NuGet?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆