[英]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.