NuGet.exe command line update for specific version

NuGet Update-Package

The PowerShell command that can be run from within Visual Studio supports a flag -Version

that allows you to upgrade to a specific version of the package.

It's a big limitation for our build server workflow that the team nuget.exe update

doesn't support this scenario, and I'm thinking of two options:

  • Modify the source code for the nuget.exe command line tool. It doesn't seem difficult, it seems that there is support for invoking UpdatePackageReference

    the version specification that the switch is using -Safe

    .

  • Write a command line extension (like described here ), similar to NuGet.Analyze , which adds a nuget.exe update command for the version. From what I can tell, this will require duplicating most of the code in the class UpdateCommand

    , 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 a deeper understanding of what the correct route would be, or if there is an alternative solution?

+3


source to share


1 answer


I ended up trying the first option, and it was easier than I originally thought. There is already support for updating a specific version of the API and I just had to add the -Version parameter for the command line tool and call it if specified.

I created a NuGet 2.8.2 fork with the change shown here: https://github.com/rikoe/nuget/tree/2.8.2 .



I will try to submit a pull request to add it to a future NuGet version.

+2


source







All Articles