Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I update a single nuget package in a project from the command line?

I am trying to update a single package in a csproj with multiple dependencies. That is, the packages.config file looks like this:

<packages>
  <package id="PackageA" version="1.2.1" targetFramework="net40" />
  <package id="PackageB" version="2.3.4" targetFramework="net40" />
  <package id="PackageC" version="1.0.0" targetFramework="net40" />
</packages>

I'd like to update PackageA without updating the others. I see that Update-Package in the Visual Studio package manager has this capability, but this needs to run on a TFS build machine.

Is there a way to do this from the command line? The anticipated workflow is the build machine running

  1. Nuget.exe restore
  2. Nuget.exe update (on each csproj file)

But the update command does not allow us to specify which package to update on. I know there is an allowedVersions tag for the packages, but that is would require us to change the packages.config file when creating different branches that require different components to update or not, whereas a package-specific, csproj-specific command-line would allow us to associate the dependencies to update with each TFS branch via its build definitions.

like image 873
NextInLine Avatar asked Jan 16 '15 22:01

NextInLine


1 Answers

nuget.exe update has an -Id argument that specifies the project. So, for instance,

nuget.exe update X.csproj -Id PackageA
like image 132
NextInLine Avatar answered Oct 18 '22 18:10

NextInLine