(NuGet CLI) 的 sources 命令

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

管理位於使用者範圍組態檔或指定組態檔中的來源清單。 使用者範圍組態檔位於 %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

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

  • -src|-Source

    套件 () 來源的路徑。

  • -StorePasswordInClearText

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

  • -UserName

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

  • -ValidAuthenticationTypes

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

  • -Verbosity [normal|quiet|detailed]

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

注意

請務必在與nuget.exe相同的使用者內容下新增來源的密碼,以存取套件來源。 密碼會以加密方式儲存在組態檔中,而且只能在加密的相同使用者內容中解密。 例如,當您使用組建伺服器來還原 NuGet 套件時,密碼必須與建置伺服器工作執行所在的相同 Windows 使用者加密。

另請參閱 環境變數

範例

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