最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Issue with dotnet restore (or dotnet new webapi) command in an ASP.NET Core project on Linux - Stack Overflow

programmeradmin3浏览0评论

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.

Share Improve this question asked Feb 17 at 14:58 MatheusMatheus 11 bronze badge New contributor Matheus is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
Add a comment  | 

1 Answer 1

Reset to default 0

Try 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

发布评论

评论列表(0)

  1. 暂无评论