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