繁体   English   中英

连接到Azure Devops私有NuGet在vs代码中

[英]Connecting to an Azure Devops private NuGet in vs code

我们有一个私人NuGet饲料。 它一直与Visual Studio 我们的开发人员通过他们的Azure帐户与私有Feed连接。 移动到vs代码时,我想保留相同的功能。

使用此处的文档我将nuget.config添加到我的解决方案文件夹中。 配置看起来与文档完全一样,除了它有我们的私人提要。

<?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您只需登录即可连接到源。 vs代码的这个选项在哪里? 我目前收到下面的错误消息,这是一件好事,因为显然我没有经过身份验证。 我期待某种对话框弹出或不得不在某处输入我的凭据。 据我所知,dotnet restore命令也没有任何提供凭据的方法。

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创建一个服务帐户是一个太过分了吗?

<packageSourceCredentials>
    <Contoso>
        <add key="Username" value="user@contoso.com" />
        <add key="ClearTextPassword" value="33f!!lloppa" />
    </Contoso>
</packageSourceCredentials>

如何使用vs代码连接到Azure Devops上的私有NuGet订阅源而不保存文件中的凭据?

如何使用vs代码连接到Azure Devops上的私有NuGet订阅源而不保存文件中的凭据?

我恐怕你现在必须在nuget.config文件中保存凭据。

当您登录Visual Studio并使用凭据连接到订阅源时,Visual Studio将验证凭据并使用登录凭据将其保存在Visual Studio中:

在此输入图像描述

但Visual Studio代码没有这样的签名选项。 因此,我们必须将凭据放在nuget.config文件中。

此外,还有一个用户声音,您可以投票并添加您对此反馈的评论。 当有足够的社区投票并为此反馈添加评论时,产品团队成员将认真对待此反馈:

能够使用VSTS包管理器与Visual Studio代码(VS代码)

希望这可以帮助。

我们最终使用https://github.com/Microsoft/artifacts-credprovider for VS Code。 它工作得很好。 只需按照步骤安装Microsoft.NuGet.CredentialProvider即可。 之后,您应该能够使用命令“dotnet restore --interactive”恢复软件包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM