简体   繁体   English

如何从命令行更新项目中的单个nuget包?

[英]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. 我正在尝试使用多个依赖项更新csproj中的单个包。 That is, the packages.config file looks like this: 也就是说,packages.config文件如下所示:

<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. 我想更新PackageA而不更新其他的。 I see that Update-Package in the Visual Studio package manager has this capability , but this needs to run on a TFS build machine. 我看到Visual Studio包管理器中的Update-Package具有此功能 ,但这需要在TFS构建计算机上运行。

Is there a way to do this from the command line? 有没有办法从命令行执行此操作? The anticipated workflow is the build machine running 预期的工作流程是构建机器运行

  1. Nuget.exe restore Nuget.exe还原
  2. Nuget.exe update (on each csproj file) Nuget.exe更新 (在每个csproj文件上)

But the update command does not allow us to specify which package to update on. 但是update命令不允许我们指定要更新的包。 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. 我知道包有一个allowedVersions标记,但是这需要我们在创建需要不同组件来更新的不同分支时更改packages.config文件,而特定于包的,特定于csproj的命令行会允许我们通过其构建定义将依赖关系与每个TFS分支相关联。

nuget.exe update has an -Id argument that specifies the project. nuget.exe update有一个-Id指定项目的说法。 So, for instance, 所以,例如,

nuget.exe update X.csproj -Id PackageA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从命令行编译 MSVC 项目中的单个源文件? - How do I compile a single source file within an MSVC project from the command line? 如何使用命令行在我的项目上执行SVN更新 - How to do SVN Update on my project using the command line 如何在Xcode中打包和发布Foundation命令行工具? - How do I package and publish a Foundation command line tool in Xcode? 使用命令行检查nuget包是否存在 - Check if nuget package exists using command line Nuget自动软件包还原在命令行上失败 - Nuget Automatic Package Restore fails on command line 可安装的distutils软件包:如何从也是同一软件包一部分的命令行脚本中导入软件包模块? - Installable distutils packages: How do I import package modules from command line scripts which are also part of the same package? 如何从命令行编译 Visual Studio 项目? - How do I compile a Visual Studio project from the command-line? 如何从命令行在 Java Gradle 项目中运行 main 方法? - How do I run a main method in a Java Gradle project from command line? 如何从命令行为Borland C ++ Builder 5构建项目文件和包? - How do I build project files and packages for Borland C++ Builder 5 from the command line? 如何从命令行构建Safari扩展包? - How can I build a Safari extension package from the command line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM