Azure DevOps:管道无法使用工件中的NuGet包

时间:2020-03-03 18:53:12

标签: azure-devops nuget

我正尝试以多种方式使用Azure DevOps Server 2019(NéeTFS)项目:

  • 回购功能可保存代码,
  • 工件功能可添加一些私有软件包,
  • 管道功能可用于配置CI(主要是拉包,从代码构建,发布到登台服务器)

(大概这种集成就是重点。)

我的管道有一个 .NET Core Restore 步骤,该步骤在存储库中将 NuGet.config的路径设置为自定义配置。到目前为止,一切都很好。

配置如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />

    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="(some private server)" value="http://nuget.example/NuGet" /> <!-- (this one works fine!) -->
    <add key="(the actual private feed in question)" value="https://azure-devops.example/MyCollection/_packaging/MyProject/nuget/v3/index.json" />
  </packageSources>
</configuration>

在构建日志中,我确实看到该配置受到尊重,因为使用了上述所有三个源。但是,第三个失败并显示错误:

         NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://azure-devops.example/MyCollection/_packaging/MyProject/nuget/v3/index.json.
          ---> System.ComponentModel.Win32Exception (0x8009030E): No credentials are available in the security package.
            at System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatusPal& statusCode)
            at System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob)
            at System.Net.Http.AuthenticationHelper.SendWithNtAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean isProxyAuth, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
            at System.Net.Http.HttpConnectionPool.SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
            at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
            at System.Net.Http.AuthenticationHelper.SendWithAuthAsync(HttpRequestMessage request, Uri authUri, ICredentials credentials, Boolean preAuthenticate, Boolean isProxyAuth, Boolean doRequestAuth, HttpConnectionPool pool, CancellationToken cancellationToken)
            at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
            at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
            at NuGet.Protocol.ServerWarningLogHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
            at NuGet.Protocol.HttpSourceAuthenticationHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
            at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
            at NuGet.Protocol.TimeoutUtility.StartWithTimeout[T](Func`2 getTask, TimeSpan timeout, String timeoutMessage, CancellationToken token)
            at NuGet.Protocol.HttpRetryHandler.SendAsync(HttpRetryHandlerRequest request, ILogger log, CancellationToken cancellationToken)
            at NuGet.Protocol.HttpSource.GetThrottledResponse(Func`1 requestFactory, TimeSpan requestTimeout, TimeSpan downloadTimeout, Int32 maxTries, Guid sessionId, ILogger log, CancellationToken cancellationToken)
            at NuGet.Protocol.HttpSource.<>c__DisplayClass14_0`1.<<GetAsync>b__0>d.MoveNext()

这个看起来像是一些身份验证问题,但实际上听起来好像并没有 try 进行身份验证。

我用尽了所有可能的原因:

  • 构建代理以其自己的用户tfsbuildagent运行。我已经明确地添加了feed permissions作为贡献者(即使读者可能足够了)。
  • 为了防止本地用户无法正常工作,我将其从本地用户更改为Active Directory域中的一个。
  • 我已从2019年升级到2019.1.1,以免是一个错误。
  • 我尝试将服务连接添加到此组织/馆藏之外的供稿的凭据字段中。但是这个提要不是在外面。这是同一项目!

我的猜测是我需要告诉它如何进行身份验证(仅使用当前的Windows凭据),但是我无法从异常中辨别出它的尝试和失败之处。

1 个答案:

答案 0 :(得分:2)

Azure DevOps Server 2019中的dotnet restore任务似乎有问题。在github/azure-pipelines-tasks中这仍然是一个未解决的问题。

一种解决方法::您可以使用命令行任务来直接调用dotnet / nuget(latest nuget.exe)CLI,以为您的解决方案还原nuget程序包。 (在构建服务器中,请先成功还原这些程序包,然后再在Azure Devops Server中还原该程序包)

更多详细信息和更多可用的解决方法,您可以参考这位Microsoft工程师的suggestions