Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\aspnetapp.csproj]

Tags:

docker

https://github.com/dotnet/dotnet-docker-samples/tree/master/aspnetapp

Docker command docker build -t aspnetapp.

I am getting an error for docker build command as

C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\aspnetapp.csproj]

error message screenshot

[1]PS C:\Users\pssharma\dotnet-docker-samples\aspnetapp> docker build -t aspnetapp . Sending build context to Docker daemon  2.444MB Step 1/10 : FROM microsoft/aspnetcore-build:2.0 AS build-env  ---> eb21d939e0d8 Step 2/10 : WORKDIR /app  ---> Using cache  ---> d4ec30216ed7 Step 3/10 : COPY *.csproj ./  ---> Using cache  ---> 2ff39b5e6cb4 Step 4/10 : RUN dotnet restore  ---> Running in 776764a35311   Restoring packages for C:\app\aspnetapp.csproj...   Restoring packages for C:\app\aspnetapp.csproj... C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\asp C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error :   An error occurred while sending the request. [C:\app\aspnetapp.csproj] C:\Program Files\dotnet\sdk\2.1.105\NuGet.targets(104,5): error :   The operation timed out [C:\app\aspnetapp.csproj] 

The following command returned a non-zero code: 1

powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore 

error message screenshot

like image 712
Pavan sharma Avatar asked Apr 26 '18 09:04

Pavan sharma


1 Answers

This appears to happen when there are multiple network adaptors present for the host and the priority of said adaptor is misconfigured. Run the following to display a table of your network adaptors:

Get-NetIPInterface -AddressFamily IPv4 | Sort-Object -Property InterfaceMetric -Descending 

You want your primary adaptor (in my case wifi) to have the lowest InterfaceMetric.

Set-NetIPInterface -InterfaceAlias 'Wi-Fi' -InterfaceMetric 1 

My network adaptor table for reference: enter image description here

See this github thread for more information: https://github.com/docker/for-win/issues/2760#issuecomment-430889666

like image 81
PontiusTheBarbarian Avatar answered Sep 23 '22 03:09

PontiusTheBarbarian