16

I have a dotnet core project which builds fine locally but throws the following error many times:

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).

This error appears in the VSTS build log for every package used in the project.

Opening the link shows this:

{
$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
}

Though I do not have a NuGet.Config in the project folder, I do have one in the parent folder:

<?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>

I will also get this error (but only for 1 or 2 packages in the log):

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]

If all I get for an application is the first error then the build succeeds, but if I get 1 or more of the second error the build fails.

What do I need to do in order to tell dotnet core where to source the packages from?

[EDIT] I have tried placing the NuGet.Config in the project folder, to no avail.

[EDIT-2] I have it working. The solution was to place the NuGet sources in the csproj file, as described here: https://stackoverflow.com/a/56231929/71376

Matt W
  • 11,753
  • 25
  • 118
  • 215
  • 1
    Have you use the dotnet restore task to restore the nuget packages before you build the pipeline? If yes, could you please share your dotnet restore task build pipeline definition to us? – Leo Liu Jul 29 '19 at 08:49
  • 1
    Again, AFAIK, there is an issue on `.NET SDK 2.1.500`, not sure if it fixed at 2.1.701, as workaround, you can try to add the Microsoft Visual Studio Offline Packages package source in the nuget.config to check if it works for you:https://github.com/NuGet/Home/issues/7524 – Leo Liu Jul 29 '19 at 08:51
  • The build pipeline does use a restore task in a powershell script but I don't think I can share the script. I will need to check the SDK version but I simply haven't had time. I will get back to you when I can. Thank you for the info. – Matt W Aug 01 '19 at 05:02
  • 1
    The "Use .NET Core" step is configured to install version "2.1.x" and the PS script simply performs a dotnet restore on the specific csproj file. As the pipeline is working now I'm not going to add the offline packages unless it breaks again. Thanks for the advice. – Matt W Aug 02 '19 at 05:08
  • Im having the same problem. Using VS2022 preview and getting this problem in build pipeline. The final solution was that you skipped Nuget.config in solution and added packages soruces in project files instead? – Magnus Backeus Sep 07 '21 at 07:44

0 Answers0