5

我有一个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).

此错误出现在项目中使用的每个包的 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
}

虽然我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>

我也会收到此错误(但仅适用于日志中的 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]

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

我需要做什么才能知道dotnet core从哪里采购包裹?

[编辑]我尝试将其NuGet.Config放在项目文件夹中,但无济于事。

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

4

0 回答 0