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

后端 未结 13 1615
温柔的废话
温柔的废话 2021-02-12 01:45

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

Docker command docker build -t aspnetapp.

I am getting an error for docker bui

相关标签:
13条回答
  • 2021-02-12 01:55

    For me, this issue appeared randomly (along with multiple similar issues, such as "permission denied for nuget" etc. To fix that, restart Visual Studio) For windows, it was fixed by restarting docker service and restarting Visual Studio (2017).

    1. Shut down Docker and Visual Studio
    2. Winkey + R, type in services.msc
    3. Find Docker for Windows Service and restart it (restarting Docker normally is not enough)
    4. Start Docker and Visual Studio
    0 讨论(0)
  • One more reason why this happens. If your docker file targeting windows container and your docker is running linux mode or vice versa.

    0 讨论(0)
  • 2021-02-12 01:57

    In my case, in Dockerfile, I have

    FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
    

    and

    FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
    

    But I only have .net 2.1 installed (view by dotnet --list-sdks). So I have to change 2.2 to 2.1 to make it work.

    0 讨论(0)
  • 2021-02-12 02:00

    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:

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

    0 讨论(0)
  • 2021-02-12 02:06

    I got this working by passing in docker build environment variables from the command line like so:

    docker build --build-arg HTTP_PROXY=http://{un}:{pw}@{proxyhost}:{port} --build-arg HTTPS_PROXY=http://{un}:{pw}@{proxyhost}:{port} -t aspnetapp .

    *note that your username must be url encoded (ei. DOMAIN\name => DOMAIN%5Cname)

    0 讨论(0)
  • 2021-02-12 02:11

    Open CMD or Powershell and run: dotnet nuget locals http-cache --clear

    https://status.nuget.org/

    0 讨论(0)
提交回复
热议问题