簡體   English   中英

添加需要 VS2015 憑據的 NuGet Package 源

[英]Adding a NuGet Package Source that requires credentials with VS2015

我正在嘗試設置需要憑據的 NuGet package 源。

這是說明

我有最新版本的 Visual Studio 2015,所有內容都是最新的。 我知道如何通過 VS2015 中的 UI 添加 package 源,但這樣做時無法指定憑據。

他們要求我運行的命令是:

NuGet Sources Add -Name "telerik.com" -Source "https://nuget.telerik.com/nuget" -UserName "<your login email>" -Password "<your password>"

我知道我需要一個 nuget.exe 來運行這個命令,但是有一種方法可以直接通過 VS 執行此操作而無需下載任何東西,不是嗎?

如果我下載 NuGet.exe,打開命令提示符並導航到它以運行該命令,那么我是否能夠從 Visual Studio 的 NuGet Package 管理器 UI 中看到它並從 Visual Studio 的 NuGet Package 管理器控制台訪問它? 我對它將如何與 Visual Studio 內置的 NuGet Package 管理器集成感到困惑。

我發現您需要將 nuget.exe 下載到您的計算機,打開命令提示符並導航到它。 然后運行命令以使用憑據添加包源:

NuGet Sources Add -Name "telerik.com" -Source "https://nuget.telerik.com/nuget" -UserName "<your login email>" -Password "<your password>"

重新啟動 Visual Studio,包源將添加到 Nuget UI 和 Nuget 命令行的列表中。

如果您使用的是 SSO 並且 Windows 憑據修復對您不起作用,只需退出 Visual Studio,然后重新登錄,然后重新啟動 Visual Studio; 然后,將修復 401 NuGet 包源錯誤。

We can update the file Nuget.config file entry as  

<add key="Telerik" value="https://nuget.telerik.com/nuget" 
UserName ="<<youremail@mail.com>>" 
Password ="<<password>>" />  

This let me build and run.

我嘗試了Blake Rivell在他的回答中描述的方法。 它對我不起作用,所以我嘗試使用-StorePasswordInClearText標志。 (參見問題中提到的說明)

然后我發現我開始處理的項目包含一個“NuGet.Config”文件。 此文件中源的顯示名稱與我通過命令行添加的名稱不同(添加到全局“NuGet.Config”文件)。 (我們不同的項目顯然使用不同的名稱)

所以它不起作用,因為它無法將源和憑據與我本地“NuGet.Config”文件中的條目相關聯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM