3

From Nuget CLI is it possible from a single command to upgrade multiple packages to the desired version?

I know we can do

nuget.exe update "FooBar.sln" MyPackage -Version 1.0

but what if I want to update 2 packages to 1.0?

This still updates to the latest version but not to the version I desire.

nuget.exe update "FooBar.sln" -Id MyPackage -Id MyPackage2 -Version 1.0

What will be the command for that and will there be any dependency on each other like both package will update only when they both are on a project (https://stackoverflow.com/a/16302774/1011959)?

Uddhav P. Gautam
  • 7,362
  • 3
  • 47
  • 64
Nikhil Agrawal
  • 47,018
  • 22
  • 121
  • 208
  • 1
    Can I know the reason why you want update multiple packages to a desired version in single nuget cli command? You can just update those packages with two nuget cli commands. – Joy Feb 26 '18 at 09:18
  • @Alex: I need to update couple of packages in a solution. One way is to do it one by one. Other way I was expecting was to send the instructions in a single command. I know this can happen in Visual Studio Nuget Package Console but was thinking if this can be done from nuget cli. – Nikhil Agrawal Feb 26 '18 at 14:01
  • This seems to be the best documentation I could find. It shows among others how to update all packages in one solution: https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages Alternatively, I think Paket may offer what you need: https://fsprojects.github.io/Paket/ – Arwin Feb 27 '18 at 11:41
  • FYI - `nuget.exe` CLI has been superseded by [`dotnet` CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x). – NightOwl888 Feb 28 '18 at 22:44
  • @NightOwl888: Yes, but there's no command to `update-package` as of today. – Nikhil Agrawal Mar 01 '18 at 06:56

1 Answers1

7

It's possible to specify package version only when you update one package. If you want to do it with NuGet Cli and in one command, you can join several commands like that

nuget.exe update "FooBar.sln" MyPackage -Version 1.0 && nuget.exe update "FooBar.sln" MyPackage2 -Version 2.0

With this approach you can specify different versions for different packages.

witalego
  • 551
  • 3
  • 7