[英]NuGet.exe command-line update to specific version
The NuGet Update-Package
PowerShell command which can be run from inside Visual Studio has supported for a -Version
flag which allows updating to a specific version of a package. 可以从Visual Studio内部运行的NuGet Update-Package
PowerShell命令支持-Version
标志,该标志允许更新到特定版本的软件包。
It is a big limitation for our build server workflow that the nuget.exe update
command doesn't support this scenario, and I am thinking of two options: 对于我们的构建服务器工作流来说, nuget.exe update
命令不支持这种情况是一个很大的限制,我想到两个选项:
Modify the nuget.exe command line tool source code. 修改nuget.exe命令行工具源代码。 This doesn't seem hard, there already seems to be support for calling UpdatePackageReference
with a version specification, which is used by the -Safe
switch. 这似乎并不难,似乎已经支持使用-Safe
开关使用的版本规范调用UpdatePackageReference
。
Write a command-line extension (eg as explained here ), similar to NuGet.Analyze , that adds a version-specific update command to nuget.exe. 写一个命令行扩展(例如,作为解释在这里 ),类似于NuGet.Analyze ,增加了一个特定版本更新命令nuget.exe。 From what I can tell, though, this will require duplicating most of the code in the UpdateCommand
class, is most of its key methods are internal or private. 但是,据我所知,这将需要复制UpdateCommand
类中的大多数代码,其大多数关键方法是内部或私有的。
Does anyone with more experience with the nuget.exe command-line tool (or writing extensions for it) have more insight into what the right route would be, or if there is an alternative solution? 有没有使用nuget.exe命令行工具(或为其编写扩展)的经验的人有更深入了解正确的路线是什么,或者是否有替代解决方案?
I ended up trying the first option, and it was easier than I initially thought. 我最终尝试了第一个选项,它比我最初想的要容易。 There is already support for updating to a specific version in the API, and I simply had to add a -Version option for the command line tool, and invoke it if specified. 已经支持更新到API中的特定版本,我只需为命令行工具添加-Version选项,并在指定时调用它。
I have created a fork of NuGet 2.8.2 with the change applied here: https://github.com/rikoe/nuget/tree/2.8.2 . 我已经创建了一个NuGet 2.8.2的分支,并在此处应用了更改: https : //github.com/rikoe/nuget/tree/2.8.2 。
I will try to submit a pull request to get it added to a future version of NuGet. 我将尝试提交拉取请求,以将其添加到NuGet的未来版本中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.