sources 命令 (NuGet CLI)

適用於: 套件耗用量、發佈 • 支援的版本: 全部

管理位於用戶範圍組態檔或指定組態檔中的來源清單。 用戶範圍組態檔位於 %appdata%\NuGet\NuGet.Config (Windows) 和 ~/.nuget/NuGet/NuGet.Config (Mac/Linux)。

請注意,nuget.org 的來源 URL 是 https://api.nuget.org/v3/index.json

使用方式

nuget sources <operation> -Name <name> -Source <source>

其中 <operation> 是其中一個 List、Add、Remove、Enable、DisableUpdate<name> 是來源的名稱,而 <source> 是來源的 URL。 您一次只能操作一個來源。

選項。

  • -ConfigFile

    要套用的 NuGet 組態檔。 如果未指定, %AppData%\NuGet\NuGet.Config 則會使用 (Windows) 或 ~/.nuget/NuGet/NuGet.Config~/.config/NuGet/NuGet.Config (Mac/Linux)。 請參閱 在 Mac/Linux 上,用戶層級組態檔位置會因工具而異。

  • -ForceEnglishOutput

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

  • -Format

    list適用於動作,可以是 Detailed (預設值) 或 Short

  • -?|-help

    顯示命令的說明資訊。

  • -Name

    來源名稱。

  • -NonInteractive

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

  • -Password

    指定使用來源進行驗證的密碼。

    注意

    請注意,只有 Windows 支援加密的密碼。 此外,他們只能在同一部計算機上和原本加密它們的相同使用者解密。

  • -src|-Source

    套件來源的路徑。

  • -StorePasswordInClearText

    表示將密碼儲存在未加密的文字中,而不是儲存加密表單的預設行為。

    警告

    強烈建議不要將密碼儲存在純文本中。 如需安全地管理認證的詳細資訊,請參閱 從私人摘要取用套件的安全性最佳做法。

  • -UserName

    指定用來向來源進行驗證的用戶名稱。

  • -ValidAuthenticationTypes

    此來源的有效驗證類型逗號分隔清單。 根據預設,所有驗證類型都是有效的。 範例:basic,negotiate

  • -ProtocolVersion

    要使用的 NuGet 伺服器通訊協定版本。 如需詳細資訊,請參閱 NuGet.Config 的 packageSources 檔

    可從 6.8 版的 NuGet 命令行取得。

  • -Verbosity [normal|quiet|detailed]

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

另請參閱 環境變數

範例

nuget sources Add -Name "MyServer" -Source \\myserver\packages

nuget sources Disable -Name "MyServer"

nuget sources Enable -Name "nuget.org"

nuget sources add -name foo.bar -source C:\NuGet\local -username foo -password bar -StorePasswordInClearText -configfile %AppData%\NuGet\my.config

nuget sources Update -Name "nuget.org" -ProtocolVersion 3