setapikey 命令 (NuGet CLI)

适用于:包使用、发布 • 支持的版本:全部

将给定服务器 URL 的 API 密钥保存到 NuGet.Config,从而无需为后续命令输入 API 密钥。

使用情况

nuget setapikey <key> -Source <url> [options]

其中,<source> 可标识出服务器,而 <key> 为要保存的密钥。 如果省略 <source>,则假定为 nuget.org。

注意

API 密钥不用于向专用源进行身份验证。 请参考 nuget sources 命令来管理用于向源进行身份验证的凭据。 API 密钥可以从单个 NuGet 服务器获取。 若要为 nuget.org 创建和管理 APIKey,请参阅 acquire-an-api-key

选项

  • -ConfigFile

    要应用的 NuGet 配置文件。 如果未指定,则使用 %AppData%\NuGet\NuGet.Config(适用于 Windows)或是 ~/.nuget/NuGet/NuGet.Config~/.config/NuGet/NuGet.Config(适用于 Mac/Linux)。 请参阅在 Mac/Linux 上,用户级配置文件位置因工具而异。

  • -ForceEnglishOutput

    (3.5+) 使用固定的、基于英语的区域性强制 nuget.exe 运行。

  • -?|-help

    显示此命令的帮助信息。

  • -NonInteractive

    不为用户输入或确认显示提示。

  • -src|-Source

    其中的 API 密钥有效的服务器 URL。

  • -Verbosity [normal|quiet|detailed]

    指定输出中显示的细节量:normal(默认值)、quietdetailed

另请参阅环境变量

示例

nuget setapikey 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a

nuget setapikey 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -source https://example.com/nugetfeed