c# - 如何安装特定版本的nuget?

标签 c# .net visual-studio nuget

我正在解决特定版本的 nuget 和 msbuild 的一些问题,因此需要降级 nuget 版本:

Build failures with Mono 5.14.0.177, msbuild 15.0, nuget 4.7.1 on Travis CI, but not reproducible in VirtualBox

可以使用以下命令将 Nuget 更新到最新版本:

nuget update -self

但是似乎不支持安装特定版本的 nuget,这仍然安装最新版本的 nuget:

nuget update -self -Version 4.6.2

这失败并出现 nuget not found 错误:

nuget 安装 nuget -版本 4.6.2

https://learn.microsoft.com/en-us/nuget/tools/cli-ref-install

https://learn.microsoft.com/en-us/nuget/tools/cli-ref-update


编辑:

查看 nuget 源代码,开发人员假设更新应该始终发生在最新版本上:

https://github.com/NuGet/NuGet.Client/blob/3803820961f4d61c06d07b179dab1d0439ec0d91/src/NuGet.Clients/NuGet.CommandLine/Common/SelfUpdater.cs#L85

// Check to see if an update is needed
if (package == null || version >= package.Version)

非常可悲的决定,微软!因此提交了一个 PR,但被拒绝了:

https://github.com/NuGet/NuGet.Client/pull/2422

最佳答案

How to install a specific version of nuget?

根据文档NuGet CLI reference :

Each download is the nuget.exe file directly. Instruct your browser to save the file to a folder of your choice. The file is not an installer; you won't see anything if you run it directly from the browser.

我们可以知道,NuGet.exe 不是安装程序。您可以从nuget.org 下载您想要的版本。 ,然后替换本地磁盘上的那个。

虽然NuGet团队提供了命令行nuget update -self,可以用来将nuget.exe更新到最新版本,就像你说的, nuget update 命令不支持更新指定版本的 nuget.exe。所以,我认为你的 PR 是合理的,但应该放在低优先级。因为我们可以通过手动下载来更新nuget.exe

希望这清楚并有所帮助。

关于c# - 如何安装特定版本的nuget?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52287500/

相关文章:

c# - 如何在 Visual Studio 中打开现有的 azure 函数?

c# - 类似于 C# 的 jMonkey 引擎

c# - 有没有办法直接查询 Entity Framework Core 使用的内存数据库?

c# - 为什么一路往下用Async/await

c - c89 中的 fmax 和 fmin 替代方案

c - const 字符串动态数组的正确类型

c# - Visual Studio : debug multiple projects at the same time?

c# - Entity Framework 中的僵尸对象

c# - 使用 WebView 全屏制作 XAML 控件

c# - 如何使用c#在mysql命令中使用通配符%