question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet restore does not try all sources for restoring

See original GitHub issue

Steps to reproduce

1-Create a project that references packages from public nuget, some myget feed and a private feed that requires authentication.

2-Add Nuget.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    <add key="myget" value="https://www.myget.org/F/***/api/v3/index.json" />
    <add key="auth" value="https://nuget.***.com/nuget" />
  </packageSources>
  <packageSourceCredentials>
    <auth>
      <add key="Username" value="****" />
      <add key="Password" value="****" />
    </auth>
  </packageSourceCredentials>
</configuration>

Note that the auth feed uses version 2.

3-Run the following dotnet restore --configfile NuGet.config

Expected behavior

Packages are restored.

Actual behavior

dotnet restore tries to use only the auth feed to restore packages that reside in public nuget/myget.

Retrying 'FindPackagesByIdAsyncCore' for source 'https://[auth-feed]/FindPackagesById()?id='Microsoft.EntityFrameworkCore.SqlServer''.
Key not valid for use in specified state
Retrying 'FindPackagesByIdAsyncCore' for source 'https://[auth-feed]/FindPackagesById()?id='Microsoft.EntityFrameworkCore.SqlServer''.
Key not valid for use in specified state
Retrying 'FindPackagesByIdAsyncCore' for source 'https://[auth-feed]/FindPackagesById()?id='[myget-package-1]''.
Key not valid for use in specified state
Retrying 'FindPackagesByIdAsyncCore' for source 'https://[auth-feed]/FindPackagesById()?id='[myget-package-1]''.
Key not valid for use in specified state
Retrying 'FindPackagesByIdAsyncCore' for source 'https://[auth-feed]/FindPackagesById()?id='[myget-package-2]''.
Key not valid for use in specified state
Retrying 'FindPackagesByIdAsyncCore' for source 'https://[auth-feed]/FindPackagesById()?id='[myget-package-2]''.
Key not valid for use in specified state
C:\dotnet-sdk\sdk\1.0.0\NuGet.targets(97,5): error : Failed to retrieve information about '[myget-package-1]' from remote source 'https://[auth-feed]/FindPackagesById()?id='[myget-package-1]''. [D:\a\1\s\***.sln]
C:\dotnet-sdk\sdk\1.0.0\NuGet.targets(97,5): error :   Key not valid for use in specified state [D:\a\1\s\***.sln]

Environment data

dotnet --info output: 1.0.0

I should add that this error does not happen on my local machine, in fact it runs just fine. It only happens on VSTS, I use the dotnet-install.ps1 script to install 1.0.0 as following:

dotnet-install.ps1 -version "$(SdkVersion)" -installDir $(SdkPath) -Architecture x64 where: SdkVersion=1.0.0 SdkPath=C:\dotnet-sdk

Am I doing something wrong here…?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
TheCriticalPathcommented, Nov 6, 2017

Has anyone seen a resolution or workaround when using a docker container for builds?

0reactions
ImAMightyPiratecommented, Aug 7, 2020

Just in case anyone else ever finds this error via Google. We encountered this error because someone had missed a trailing forward slash from one of our NuGet feed URLs (hosted on ProGet) making it an invalid URL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet restore command - .NET CLI
Learn how to restore dependencies and project-specific tools with the dotnet restore command.
Read more >
docker - dotnet restore looking in wrong nuget-source
The package manager was trying to get packages from private feed that supposed to be retrieved from the nuget.org. Thanks to the link...
Read more >
restoring packages from nuget source fails if custom ...
I need to restore packages from the default nuget source but it fails because I also have a custom source that is only...
Read more >
Dotnet restore vs nuget restore. Share. In my code repo, there
I am trying to restore NuGet packages in my project using the CLI. ... build is . nuget\packages) is considered a source not...
Read more >
[REGRESSION] Package restore not working as expected
Running dotnet restore from PWSH works correctly as expected. The following log was shown in the Nuget -> Log tab: @ Restoring packages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found