將套件推送至套件來源並發佈。

NuGet 的預設設定是藉由載入 %AppData%\NuGet\NuGet.Config (Windows) 或 ~/.nuget/NuGet/NuGet.Config (Mac/Linux) 來取得,然後載入從磁碟驅動器根目錄開始並結束目前 Nuget.Config .nuget\Nuget.Config 目錄的任何檔案 (請參閱 常見的 NuGet 設定

Usage

nuget push <packagePath> [options]

其中 <packagePath> 識別要推送至伺服器的套件。

-AllowInsecureConnections 允許推送至 HTTP 來源 (不安全)。 如需詳細資訊,請參閱 https://aka.ms/nuget-https-everywhere

  • -ApiKey

    目標存放庫的 API 金鑰。 如果不存在,則使用設定檔中指定的檔案。

  • -ConfigFile

    要套用的 NuGet 組態檔。 如果未指定, %AppData%\NuGet\NuGet.Config 則使用 (Windows) 或 ~/.nuget/NuGet/NuGet.Config~/.config/NuGet/NuGet.Config (Mac/Linux)。

  • -DisableBuffering

    在推送至 HTTP(s) 伺服器時停用緩衝,以減少記憶體使用量。 注意:使用此選項時,整合式 Windows 驗證可能無法運作。

  • -ForceEnglishOutput

    (3.5+) 強制 nuget.exe 使用不變的英文型文化特性來執行。

  • -?|-help

    顯示指令的說明資訊。

  • -NonInteractive

    隱藏使用者輸入或確認的提示。

  • -NoServiceEndpoint

    不會附加 api/v2/packages 至來源 URL。

  • -NoSymbols

    (3.5+) 如果符號套件存在,則不會推送至符號伺服器。

  • -src|-Source

    指定伺服器 URL。 NuGet 會識別 UNC 或本機資料夾來源,並只會將檔案複製到該處,而不是使用 HTTP 推送它。 此外,從 NuGet 3.4.2 開始,除非檔案指定 DefaultPushSource 值,否則NuGet.Config這是必要參數 (請參閱設定 NuGet 行為)。

  • -SkipDuplicate

    (5.1+) 如果套件和版本已存在,請略過它並繼續推送中的下一個套件(如果有)。 如果要將套件推送至 UNC 或本機資料夾來源,則會忽略此選項。

  • -SymbolSource

    指定符號伺服器 URL。

  • -SymbolApiKey

    (3.5+) 指定 中指定的 -SymbolSourceURL 的 API 金鑰。

  • -Timeout

    指定推送至伺服器的逾時 (以秒為單位)。 預設值為 300 秒 (5 分鐘)。

  • -Verbosity [normal|quiet|detailed]

    指定輸出中顯示的詳細資料量: normal (預設值)、 quietdetailed

    另請參閱 環境變數

    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
    
  • 如需推送至 Azure Artifacts, 請參閱 Azure Artifacts 的推送檔
  •