为源重试“FindPackagesByIdAsync”

Mat*_*t W 5 build-pipeline nuget-package-restore .net-core azure-devops

我有一个dotnet core在本地构建良好的项目,但多次抛出以下错误:

Retrying 'FindPackagesByIdAsync' for source 'https://mycontrol.pkgs.visualstudio.com/_packaging/f8292c33-blah-blah-blah-e5e14bb9ba87/nuget/v3/flat2/microsoft.net.test.sdk/index.json'.
  Response status code does not indicate success: 401 (Unauthorized).
Run Code Online (Sandbox Code Playgroud)

此错误出现在项目中使用的每个包的 VSTS 构建日志中。

打开链接显示:

{
$id: "1",
innerException: null,
message: "Can't find the package 'microsoft.net.test.sdk' in feed 'MyFeeds'.",
typeName: "Microsoft.VisualStudio.Services.NuGet.WebApi.Exceptions.PackageNotFoundException, Microsoft.VisualStudio.Services.NuGet.WebApi",
typeKey: "PackageNotFoundException",
errorCode: 0,
eventId: 3000
}
Run Code Online (Sandbox Code Playgroud)

虽然我NuGet.Config在项目文件夹中没有一个,但我在父文件夹中有一个:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="_nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="_myget.org" value="https://dotnet.myget.org/F/mstestv2/api/v3/index.json" />
  </packageSources>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我也会收到此错误(但仅限于日志中的 1 或 2 个包):

C:\hostedtoolcache\windows\dotnet\sdk\2.1.701\NuGet.targets(121,5): error : Failed to retrieve information about 'specflow' from remote source 'https://apsourcecontrol.pkgs.visualstudio.com/_packaging/98e0f10f-afcb-4c74-a075-37c564e0408a/nuget/v3/flat2/specflow/index.json'. [D:\a\1\s\Testing\Tester\MsTester\MsTester.csproj]
C:\hostedtoolcache\windows\dotnet\sdk\2.1.701\NuGet.targets(121,5): error :   Response status code does not indicate success: 401 (Unauthorized). [D:\a\1\s\Testing\Tester\MsTester\MsTester.csproj]
Run Code Online (Sandbox Code Playgroud)

如果我对应用程序得到的只是第一个错误,则构建成功,但如果我得到 1 个或多个第二个错误,则构建失败。

我需要做什么才能告诉 dotnet core哪里获取包?

[编辑]我试过放置NuGet.Config项目文件夹中,但无济于事。

[EDIT-2]我让它工作了。解决方案是将NuGet源放在csproj文件中,如下所述:https : //stackoverflow.com/a/56231929/71376

小智 0

我遇到了类似的错误,但在本地构建并使用了Retrying 'FindPackagesByIdAsync'Microsoft.Azure.Functions.Worker.Extensions.DurableTask

构建失败,但即使构建失败,我也能够调试并使 Azure Functions 正常工作。

最后,我只是将该包添加到项目中。奇怪的是,没有对存储库进行 .csproj 更改,因此我相信引用已经存在,但不知何故损坏了。老实说,这部分没有 .csproj 更改,我仍然无法解释......但是构建错误已经消失了。:)