问题描述
我们有一个私人的 NuGet
供稿.它与 Visual Studio
一起运行良好.我们的开发人员通过其 Azure
帐户与私人供稿源建立联系.移至vs代码时,我想保留相同的功能.
We have a private NuGet
feed. It has been working well with Visual Studio
. Our developers connect through their Azure
account with the private feed. I'd like to keep this same functionality when moving to vs code.
使用在此处我在解决方案文件夹中添加了nuget.config.该配置看起来与文档完全一样,只不过那里有我们的私人供稿.
Using the documentation found here I added a nuget.config to my solution folder. The config looks exactly like the documentation except it has our private feed there.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- remove any machine-wide sources with <clear/> -->
<clear />
<!-- add an Azure Artifacts feed -->
<add key="PrivateFeed" value="https://pkgs.dev.azure.com/redacted/_packaging/redacted/nuget/v3/index.json" />
<!-- also get packages from the NuGet Gallery -->
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
使用 Visual Studio
,您只需登录即可连接到feed.vs代码的此选项在哪里?我目前正在接收下面的错误消息,这是一件好事,因为显然我没有通过身份验证.我期望弹出某种对话框,或者必须在某处输入我的凭据.据我所知,dotnet restore命令也没有任何提供凭据的方法.
With Visual Studio
you simply have to log in and you can connect to the feed. Where is this option for vs code? I'm currently receiving the error messages below which is a good thing because obviously I'm not authenticated. I was expecting some kind of dialog to pop up or having to enter my credentials somewhere. The dotnet restore command also does not have any way of providing credentials as far as I'm aware.
C:\Program Files\dotnet\sdk\2.1.500\NuGet.targets(114,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/redacted/_packaging/redacted/nuget/v3/index.json. [redacted]
C:\Program Files\dotnet\sdk\2.1.500\NuGet.targets(114,5): error : Response status code does not indicate success: 401 (Unauthorized). [redacted]
一些文档还提到将凭据放入 nuget.config
文件中,但是我发现这很奇怪,因为对于 Visual Studio
来说这从来没有必要,而且我也没有用户我可以在这里输入确定仅为私有 NuGet
创建服务帐户是否太过远了?
Some documentation also mentions putting credentials in the nuget.config
file but I find this very strange as this was never necessary with Visual Studio
and I also don't have a user I can just enter here. Surely creating a service account just for a private NuGet
is a step too far?
<packageSourceCredentials>
<Contoso>
<add key="Username" value="[email protected]" />
<add key="ClearTextPassword" value="33f!!lloppa" />
</Contoso>
</packageSourceCredentials>
如何使用vs代码连接到 Azure Devops
上的私有 NuGet
提要,而又不将凭据保存在文件中?
How can I connect to a private NuGet
feed on Azure Devops
with vs code without saving credentials in a file?
推荐答案
我们最终使用了 https://适用于VS Code的github.com/Microsoft/artifacts-credprovider .它真的很好.只需按照以下步骤安装Microsoft.NuGet.CredentialProvider.之后,您应该可以使用命令"dotnet restore --interactive"来还原软件包.
We ended up using https://github.com/Microsoft/artifacts-credprovider for VS Code. It works really well. Just follow the steps to install the Microsoft.NuGet.CredentialProvider. Afterwards you should be able to restore the packages with the command "dotnet restore --interactive".
这篇关于在vs代码中连接到Azure Devops私有NuGet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!