I'm trying to create an ASP.NET Core Web API project on my Linux system (Ubuntu 22.04) and facing an issue with the dotnet restore
or dotnet new
command: the process gets stuck during the restore step. Im using the dotnet new webapi -o NewApi
command (SDK 8.0).
Determining projects to restore...
/home/john/project-folder/webapp/MyWebApi.csproj : error NU1301: Unable to load the service index for source .json.
Failed to restore /home/john/project-folder/webapp/MyWebApi.csproj (in 10.09 min).
Has anyone encountered this issue before? Any ideas on how to resolve it?
Additional context:
I’ve tried creating other project types (e.g., console apps), and they work fine. The issue seems specific to Web API projects.
I confirmed that my connection to NuGet works by running:
curl .json
This returns a valid JSON response, so there’s no issue with network connectivity.
I'm trying to create an ASP.NET Core Web API project on my Linux system (Ubuntu 22.04) and facing an issue with the dotnet restore
or dotnet new
command: the process gets stuck during the restore step. Im using the dotnet new webapi -o NewApi
command (SDK 8.0).
Determining projects to restore...
/home/john/project-folder/webapp/MyWebApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget./v3/index.json.
Failed to restore /home/john/project-folder/webapp/MyWebApi.csproj (in 10.09 min).
Has anyone encountered this issue before? Any ideas on how to resolve it?
Additional context:
I’ve tried creating other project types (e.g., console apps), and they work fine. The issue seems specific to Web API projects.
I confirmed that my connection to NuGet works by running:
curl https://api.nuget./v3/index.json
This returns a valid JSON response, so there’s no issue with network connectivity.
1 Answer
Reset to default 0Try to use the following commands to check whether the NuGet source is enabled.
dotnet nuget list source
If not enabled, you can try to enable it using the dotnet nuget enable source <NAME>
command.
Or you can directly delete the NuGet.Config file in %appdata%\NuGet(the full path: C:\Users\{username}\AppData\Roaming\NuGet)
folder, and then restart the VS tools.
Besides, you could also try to add proxy settings into Nuget.Config file. Refer to this link for details: Nuget Config Section & Nuget Proxy Settings.
Reger to the following similar questions:
Nuget connection attempt failed "Unable to load the service index for source"
Visual Studio - Nuget - Unable to load the service index for source.
Visual Studio 2022 won't connect to NuGet