dotnet nuget pushdotnet nuget push

本主題適用於:✓ .NET Core 1.x SDK 和更新版本This topic applies to: ✓ .NET Core 1.x SDK and later versions

NameName

dotnet nuget push - 將套件推送至伺服器並發行。dotnet nuget push - Pushes a package to the server and publishes it.

概要Synopsis

dotnet nuget push [<ROOT>] [-d|--disable-buffering] [--force-english-output] [--interactive] [-k|--api-key] [-n|--no-symbols]
    [--no-service-endpoint] [-s|--source] [--skip-duplicate] [-sk|--symbol-api-key] [-ss|--symbol-source] [-t|--timeout]
dotnet nuget push [-h|--help]

描述Description

dotnet nuget push 命令會將套件推送至伺服器並發行。The dotnet nuget push command pushes a package to the server and publishes it. 推送命令會使用在系統 NuGet 組態檔案或組態檔案鏈中找到的伺服器及認證詳細資料。The push command uses server and credential details found in the system's NuGet config file or chain of config files. 如需組態檔的詳細資訊,請參閱設定 NuGet 行為For more information on config files, see Configuring NuGet Behavior. NuGet 預設組態的取得方式如下:載入 %AppData%\NuGet\NuGet.config (Windows) 或 $HOME/.local/share (Linux/macOS),接著從磁碟機根目錄開始直到目前目錄,載入其中的任何 nuget.config.nuget\nuget.configNuGet's default configuration is obtained by loading %AppData%\NuGet\NuGet.config (Windows) or $HOME/.local/share (Linux/macOS), then loading any nuget.config or .nuget\nuget.config starting from the root of drive and ending in the current directory.

ArgumentsArguments

  • ROOT

    指定套件推送目標的檔案路徑。Specifies the file path to the package to be pushed.

選項Options

  • -d|--disable-buffering

    推送至 HTTP(S) 伺服器時停用緩衝處理以減少記憶體使用量。Disables buffering when pushing to an HTTP(S) server to reduce memory usage.

  • --force-english-output

    強制使用非變異英文文化特性來執行應用程式。Forces the application to run using an invariant, English-based culture.

  • -h|--help

    印出命令的簡短說明。Prints out a short help for the command.

  • --interactive

    允許命令進行封鎖及要求對驗證之類的作業採取手動動作。Allows the command to block and requires manual action for operations like authentication. 自 .NET Core 2.2 SDK 起可用的選項。Option available since .NET Core 2.2 SDK.

  • -k|--api-key <API_KEY>

    伺服器的 API 金鑰。The API key for the server.

  • -n|--no-symbols

    不推送符號 (即使存在)。Doesn't push symbols (even if present).

  • --no-service-endpoint

    不會將 "api/v2/package" 附加至來源 URL。Doesn't append "api/v2/package" to the source URL. 自 .NET Core 2.1 SDK 起可用的選項。Option available since .NET Core 2.1 SDK.

  • -s|--source <SOURCE>

    指定伺服器 URL。Specifies the server URL. 除非在 NuGet 組態檔中設定 DefaultPushSource 設定值,否則此選項為必要。This option is required unless DefaultPushSource config value is set in the NuGet config file.

  • --skip-duplicate

    將多個封裝推送至 HTTP (S)伺服器時,會將任何409衝突回應視為警告,讓推送可以繼續進行。When pushing multiple packages to an HTTP(S) server, treats any 409 Conflict response as a warning so that the push can continue. 自 .NET Core 3.1 SDK 起提供。Available since .NET Core 3.1 SDK.

  • -sk|--symbol-api-key <API_KEY>

    符號伺服器的 API 金鑰。The API key for the symbol server.

  • -ss|--symbol-source <SOURCE>

    指定符號伺服器 URL。Specifies the symbol server URL.

  • -t|--timeout <TIMEOUT>

    指定推送至伺服器的逾時 (以秒為單位)。Specifies the timeout for pushing to a server in seconds. 預設為 300 秒 (5 分鐘)。Defaults to 300 seconds (5 minutes). 指定 0 (零秒) 會套用預設值。Specifying 0 (zero seconds) applies the default value.

範例Examples

  • foo.nupkg 推送至預設推送來源,指定 API 金鑰:Pushes foo.nupkg to the default push source, specifying an API key:

    dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a
    
  • foo.nupkg 推送至自訂推送來源 https://customsource,指定 API 金鑰:Push foo.nupkg to the custom push source https://customsource, specifying an API key:

    dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -s https://customsource/
    
  • foo.nupkg 推送至預設推送來源:Pushes foo.nupkg to the default push source:

    dotnet nuget push foo.nupkg
    
  • foo.symbols.nupkg 推送至預設符號來源:Pushes foo.symbols.nupkg to the default symbols source:

    dotnet nuget push foo.symbols.nupkg
    
  • foo.nupkg 推送至預設推送來源,指定 360 秒逾時:Pushes foo.nupkg to the default push source, specifying a 360-second timeout:

    dotnet nuget push foo.nupkg --timeout 360
    
  • 將目前目錄中的所有 .nupkg 檔案推送至預設推送來源:Pushes all .nupkg files in the current directory to the default push source:

    dotnet nuget push *.nupkg
    

    注意

    如果此命令無法運作,可能是舊版 SDK (.NET Core 2.1 SDK 及更舊版本) 中有 Bug 所致。If this command doesn't work, it might be due to a bug that existed in older versions of the SDK (.NET Core 2.1 SDK and earlier versions). 若要修正此問題,請升級您的 SDK 版本,或改為執行下列命令:dotnet nuget push **/*.nupkgTo fix this, upgrade your SDK version or run the following command instead: dotnet nuget push **/*.nupkg

  • 會推送所有的 nupkg檔案,即使 HTTP (S)伺服器傳回409衝突回應也一樣:Pushes all .nupkg files even if a 409 Conflict response is returned by an HTTP(S) server:

    dotnet nuget push *.nupkg --skip-duplicate