I have a problem with dotnet restore
command used in docker container behind corporate proxy.
#10 [build 6/6] RUN dotnet restore "BFG.TestApi.csproj" --verbosity n
#10 sha256:bd31c78e09fe330c27e994c0d9b5b055df2d905c280a061a634ae34765217a9a
#10 0.598 Build started 08/04/2022 06:00:42.
#10 1.000 1>Project "/src/BFG.TestApi/BFG.TestApi.csproj" on node 1 (Restore target(s)).
#10 1.000 1>_GetAllRestoreProjectPathItems:
#10 1.000 Determining projects to restore...
#10 1.252 Restore:
#10 1.252 Restoring packages for /src/BFG.TestApi/BFG.TestApi.csproj...
#10 7.564 1>/src/BFG.TestApi/BFG.TestApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
#10 13.55 1>/src/BFG.TestApi/BFG.TestApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
#10 13.57 Generating MSBuild file /src/BFG.TestApi/obj/BFG.TestApi.csproj.nuget.g.props.
#10 13.57 Generating MSBuild file /src/BFG.TestApi/obj/BFG.TestApi.csproj.nuget.g.targets.
#10 13.57 Writing assets file to disk. Path: /src/BFG.TestApi/obj/project.assets.json
#10 13.58 Failed to restore /src/BFG.TestApi/BFG.TestApi.csproj (in 12.35 sec).
#10 13.59
#10 13.59 NuGet Config files used:
#10 13.59 /src/BFG.TestApi/NuGet.Config
#10 13.59 /root/.nuget/NuGet/NuGet.Config
#10 13.59
#10 13.59 Feeds used:
#10 13.59 https://api.nuget.org/v3/index.json
#10 13.59 1>Done Building Project "/src/BFG.TestApi/BFG.TestApi.csproj" (Restore target(s)) -- FAILED.
#10 13.59
#10 13.59 Build FAILED.
#10 13.59
#10 13.59 "/src/BFG.TestApi/BFG.TestApi.csproj" (Restore target) (1) ->
#10 13.59 (Restore target) ->
#10 13.59 /src/BFG.TestApi/BFG.TestApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
#10 13.59 /src/BFG.TestApi/BFG.TestApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
#10 13.59
#10 13.59 0 Warning(s)
#10 13.59 2 Error(s)
#10 13.59
#10 13.59 Time Elapsed 00:00:12.99
#10 ERROR: executor failed running [/bin/sh -c dotnet restore "BFG.TestApi.csproj" --verbosity n]: exit code: 1
What I have tried already:
- Setting
http_proxy
,https_proxy
in container environment variables likehttp://user:password@someproxyhost.com:port
- Passing NuGet.Config file with proxy settings into project folder and also into user config path
/root/.nuget/NuGet/NuGet.Config
- I have confirmend that the proxy I am setting in container is correct because
curl https://api.nuget.org/v3/index.json
from inside container is working. - I have tried different docker images (
mcr.microsoft.com/dotnet/sdk:6.0
,mcr.microsoft.com/dotnet/sdk:7.0
, etc)
Everything without luck.. I am struggling with this blocking issue for days now. Is there any chance that I still have some configuration issues or there is a problem with dotnet restore
?
Update 1: I am using standard Dockerfile generated by VS2022 for simple WebApi project in .net 6.