简体   繁体   English

如何安装特定版本的nuget?

[英]How to install a specific version of nuget?

I'm troubleshooting some issues with specific versions of nuget and msbuild, hence need for downgrading of nuget versions: 我正在使用特定版本的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 在Travis CI上使用Mono 5.14.0.177,msbuild 15.0,nuget 4.7.1构建失败,但在VirtualBox中无法重现

Nuget can be updated to latest version with this command: Nuget可以使用以下命令更新到最新版本:

nuget update -self

However installing a specific version of nuget seems to be unsupported, this still install the latest version of nuget: 但是,安装特定版本的nuget似乎不受支持,这仍然安装最新版本的nuget:

nuget update -self -Version 4.6.2

And this fails with nuget not found error: 这失败了nuget not found错误:

nuget install nuget -Version 4.6.2

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

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


EDIT: 编辑:

Looking at nuget source code the developers made an assumption that update should always happen to the latest version: 查看nuget源代码,开发人员假设更新应始终发生在最新版本中:

https://github.com/NuGet/NuGet.Client/blob/3803820961f4d61c06d07b179dab1d0439ec0d91/src/NuGet.Clients/NuGet.CommandLine/Common/SelfUpdater.cs#L85 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)

Very sad decision, Microsoft! 非常悲伤的决定,微软! Hence submitted a PR and it was rejected: 因此提交了PR,但被拒绝了:

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

How to install a specific version of nuget? 如何安装特定版本的nuget?

According to the document NuGet CLI reference : 根据文档NuGet CLI参考

Each download is the nuget.exe file directly. 每次下载都是nuget.exe文件。 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. 如果直接从浏览器运行它,您将看不到任何内容。

We could to know, NuGet.exe is not an installer. 我们可以知道,NuGet.exe不是安装程序。 You can just download the version what you want from the nuget.org , then replace the one on the local disk. 您可以从nuget.org下载所需的版本,然后替换本地磁盘上的版本。

Although NuGet team provide the command line nuget update -self , which can be used to update the nuget.exe to the latest version, just like what have you said, nuget update command not support update nuget.exe for a specify version. 虽然NuGet团队提供命令行nuget update -self ,可以用来将nuget.exe更新到最新版本,就像你说的那样,nuget update命令不支持更新nuget.exe用于指定版本。 So, I think your PR is reasonable, but it should be at a low priority. 所以,我认为你的PR是合理的,但它应该是低优先级。 Because we can update nuget.exe by downloading manually. 因为我们可以通过手动下载来更新nuget.exe

Hope this clear and helps. 希望这清楚并有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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