无法加载源https://api.nuget.org/v3/index.json的服务索引。 [C:\app\aspnetapp.csproj] [英] Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\aspnetapp.csproj]
问题描述
https://github.com/dotnet/dotnet-docker-样本/树/主/ aspnetapp
Docker命令 docker build -t aspnetapp
。
我在docker build命令中遇到错误
I am getting an error for docker build command as
C:\Program Files \dotnet\sdk\2.1.105\NuGet.targets(104,5):错误:无法加载源 https://api.nuget.org/v3/index.json 。 [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\aspnetapp.csproj]
[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]
以下命令返回了非零代码:1
The following command returned a non-zero code: 1
powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore
推荐答案
对我来说,此问题是随机出现的(以及多个类似的问题,例如如为nuget拒绝权限等。要解决此问题,请重新启动Visual Studio)
对于 windows ,已通过重新启动docker服务并重新启动Visual Studio(2017)进行了修复。
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).
- 关闭Docker和Visual Studio
- Winkey + R,键入services.msc
- 找到适用于Windows Service的Docker并重新启动它(通常仅重启Docker是不够的)
- 启动Docker和Visual Studio
- Shut down Docker and Visual Studio
- Winkey + R, type in services.msc
- Find Docker for Windows Service and restart it (restarting Docker normally is not enough)
- Start Docker and Visual Studio
这篇关于无法加载源https://api.nuget.org/v3/index.json的服务索引。 [C:\app\aspnetapp.csproj]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!