简体   繁体   中英

Dotnet restore gives 301 error for a NuGet package

My code was working fine last night but when I tried to restore it today using dotnet restore , I get the following error.

Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.aspnetcore.identity.ui/index.json'.
  Response status code does not indicate success: 301 (Moved Permanently).
  Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/fluentvalidation/index.json'.
  Response status code does not indicate success: 301 (Moved Permanently).
  Failed to download package 'Microsoft.EntityFrameworkCore.3.1.8' from 'https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore/3.1.8/microsoft.entityframeworkcore.3.1.8.nupkg'.
  Response status code does not indicate success: 301 (Moved Permanently).
  Failed to download package 'Microsoft.EntityFrameworkCore.3.1.1' from 'https://api.nuget.org/v3-flatcontainer/microsoft.entityframeworkcore/3.1.1/microsoft.entityframeworkcore.3.1.1.nupkg'.
  Response status code does not indicate success: 301 (Moved Permanently).
  Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/microsoft.extensions.fileproviders.embedded/index.json'.
  Response status code does not indicate success: 301 (Moved Permanently).
  Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/serilog.sinks.console/index.json'.
  Response status code does not indicate success: 301 (Moved Permanently).
  Retrying 'FindPackagesByIdAsync' for source 'https://api.nuget.org/v3-flatcontainer/system.text.regularexpressions/index.json'.
  Response status code does not indicate success: 301 (Moved Permanently).

I'm using Ubuntu 20.04 and my dotnet configuration is as follows

.NET Core SDK (reflecting any global.json):
 Version:   3.1.414
 Commit:    88a3b0c5ca

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.414/

Host (useful for support):
  Version: 3.1.20
  Commit:  2833dab8c3

.NET Core SDKs installed:
  3.1.414 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.20 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

However, if I try to directly access the URLs, I am able to access them? I'm also using a VPN. Could this be due to that?

I've managed to fix my problem like this:

1- download Nuget.exe from here

2- add Nuget.exe to the windows path ( you can copy it in c:/windows/system32)

3- open the command line and navigate to your solution folder and run this command:

nuget.exe restore -DisableParallel

hope it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM