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

末鹿安然 提交于 2020-01-03 07:21:08

问题


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:


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

nuget.exe update X.csproj -Id PackageA


来源:https://stackoverflow.com/questions/27993773/how-do-i-update-a-single-nuget-package-in-a-project-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!