How do I update a single nuget package in a projec

2019-06-16 07:17发布

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.

1条回答
该账号已被封号
2楼-- · 2019-06-16 08:15

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

nuget.exe update X.csproj -Id PackageA
查看更多
登录 后发表回答