我正在解决特定版本的 nuget 和 msbuild 的一些问题,因此需要降级 nuget 版本:
可以使用以下命令将 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 源代码,开发人员假设更新应该始终发生在最新版本上:
// Check to see if an update is needed
if (package == null || version >= package.Version)
非常可悲的决定,微软!因此提交了一个 PR,但被拒绝了:
最佳答案
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/