(NuGet CLI 的推送命令) push command (NuGet CLI)

适用于: 包发布 • 支持的版本: 全部; 4.1.0 + 必需的 nuget.orgApplies to: package publishing • Supported versions: all; 4.1.0+ required for nuget.org

重要

若要将包推送到 nuget.org,必须使用 nuget.exe v 4.1.0 + 来实现所需的 nuget 协议To push packages to nuget.org you must use nuget.exe v4.1.0+, which implements the required NuGet protocols.

将包推送到包源并发布包。Pushes a package to a package source and publishes it.

通过加载 %AppData%\NuGet\NuGet.Config (Windows) 或 ~/.nuget/NuGet/NuGet.Config (Mac/Linux) ,然后加载 Nuget.Config .nuget\Nuget.Config 从驱动器的根目录开始并在当前目录中结束的任何或文件,将获取 NuGet 的默认配置 (参见 常见 NuGet 配置) NuGet's default configuration is obtained by loading %AppData%\NuGet\NuGet.Config (Windows) or ~/.nuget/NuGet/NuGet.Config (Mac/Linux), then loading any Nuget.Config or .nuget\Nuget.Config files starting from root of drive and ending in current directory (see Common NuGet configurations)

使用情况Usage

nuget push <packagePath> [options]

其中 <packagePath> 标识要推送到服务器的包。where <packagePath> identifies the package to push to the server.

选项Options

  • -ApiKey

    目标存储库的 API 密钥。The API key for the target repository. 如果不存在,则使用配置文件中指定的一个。If not present, the one specified in the config file is used.

  • -ConfigFile

    要应用的 NuGet 配置文件。The NuGet configuration file to apply. 如果未指定,则 %AppData%\NuGet\NuGet.Config 使用 (Windows) ~/.nuget/NuGet/NuGet.Config~/.config/NuGet/NuGet.Config (Mac/Linux) 。If not specified, %AppData%\NuGet\NuGet.Config (Windows), or ~/.nuget/NuGet/NuGet.Config or ~/.config/NuGet/NuGet.Config (Mac/Linux) is used.

  • -DisableBuffering

    当推送到 HTTP (s) 服务器来减少内存使用情况时,将禁用缓冲。Disables buffering when pushing to an HTTP(s) server to decrease memory usages. 注意:使用此选项时,集成的 Windows 身份验证可能不起作用。Caution: when this option is used, integrated Windows authentication might not work.

  • -ForceEnglishOutput

    * (3.5 +) * 使用固定的、基于英语的区域性强制运行 nuget.exe。(3.5+) Forces nuget.exe to run using an invariant, English-based culture.

  • -?|-help

    显示命令的帮助信息。Displays help information for the command.

  • -NonInteractive

    禁止提示用户输入或确认。Suppresses prompts for user input or confirmations.

  • -NoServiceEndpoint

    不追加 api/v2/packages 到源 URL。Does not append api/v2/packages to the source URL.

  • -NoSymbols

    * (3.5 +) * 如果符号包存在,则不会将其推送到符号服务器。(3.5+) If a symbols package exists, it will not be pushed to a symbol server.

  • -src|-Source

    指定服务器 URL。Specifies the server URL. NuGet 标识 UNC 或本地文件夹源,只是复制该文件,而不是使用 HTTP 推送它。NuGet identifies a UNC or local folder source and simply copies the file there instead of pushing it using HTTP. 此外,从 NuGet 3.4.2 开始,这是必需的参数,除非该 NuGet.Config 文件指定了 DefaultPushSource 值 (请参阅 配置 NuGet 行为) 。Also, starting with NuGet 3.4.2, this is a mandatory parameter unless the NuGet.Config file specifies a DefaultPushSource value (see Configuring NuGet behavior).

  • -SkipDuplicate

    * (5.1 +) * 如果包和版本已存在,则跳过它,并继续执行推送中的下一个包(如果有)。(5.1+) If a package and version already exists, skip it and continue with the next package in the push, if any.

  • -SymbolSource

    * (3.5 +) * 指定符号服务器 URL;推送到 nuget.org 时使用 nuget.smbsrc.net(3.5+) Specifies the symbol server URL; nuget.smbsrc.net is used when pushing to nuget.org

  • -SymbolApiKey

    * (3.5 +) * 为中指定的 URL 指定 API 密钥 -SymbolSource(3.5+) Specifies the API key for the URL specified in -SymbolSource.

  • -Timeout

    指定推送到服务器的超时值(以秒为单位)。Specifies the timeout, in seconds, for pushing to a server. 默认值为 300 秒(5 分钟)。The default is 300 seconds (5 minutes).

  • -Verbosity [normal|quiet|detailed]

    指定在输出中显示的详细信息的数量: normal (默认) 、 quietdetailedSpecifies the amount of detail displayed in the output: normal (the default), quiet, or detailed.

另请参阅 环境变量Also see Environment variables

示例Examples

nuget push foo.nupkg

nuget push foo.symbols.nupkg

nuget push foo.nupkg -Timeout 360

nuget push *.nupkg

nuget.exe push -source \\mycompany\repo\ mypackage.1.0.0.nupkg

nuget push foo.nupkg 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -Source https://api.nuget.org/v3/index.json

nuget push foo.nupkg 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a

nuget push foo.nupkg 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -src https://customsource/

:: In the example below -SkipDuplicate will skip pushing the package if package "Foo" version "5.0.2" already exists on NuGet.org
nuget push Foo.5.0.2.nupkg 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -src https://api.nuget.org/v3/index.json -SkipDuplicate