Reputation: 1699
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.
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:
Modify the nuget.exe command line tool source code. 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.
Write a command-line extension (e.g. as explained here), similar to NuGet.Analyze, that adds a version-specific update command to 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.
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?
Upvotes: 3
Views: 2283
Reputation: 1699
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.
I have created a fork of NuGet 2.8.2 with the change applied here: 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.
Upvotes: 2