如何从命令行更新项目中的单个nuget包? [英] How do I update a single nuget package in a project from the command line?

查看:776
本文介绍了如何从命令行更新项目中的单个nuget包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更新具有多个依赖关系的csproj中的单个包。也就是说,packages.config文件如下所示:

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>

我想更新 PackageA 我看到 更新程序包 strong>在Visual Studio包管理器中有这个功能,但是这需要在TFS构建机器上运行。

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更新(在每个csproj文件上)

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

strong>命令不允许我们指定要更新的包。我知道有一个allowedVersions标签的软件包,但这是需要我们更改packages.config文件时创建不同的分支,需要不同的组件更新或不更新,而特定于软件包,csproj的命令行允许我们通过其构建定义将依赖关系与每个TFS分支相关联。

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.

推荐答案

nuget。 exe update 有一个 -Id 指定项目的参数。例如,

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

nuget.exe update X.csproj -Id PackageA

这篇关于如何从命令行更新项目中的单个nuget包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆