aspnet / aspnet-docker

[Archived] ASP.NET Core Docker images for 1.x. Go to https://github.com/dotnet/dotnet-docker for 2.1 and up.
https://asp.net
719 stars 171 forks source link

dotnet restore command fails from Docker container for private NuGet feed #317

Closed netspark closed 6 years ago

netspark commented 7 years ago

Private NuGet feed credentials, provided in either nuget.config packageSourceCredentials section or in NuGetPackageSourceCredentials_feedName environment variable are ignored, however, the feed source is recognized.

Steps to reproduce the issue

  1. Create the following docker-compose.ci.build.yml file:
    
    version: '3'

services: ci-build: image: microsoft/aspnetcore-build:1.0-2.0 volumes:

Expected behavior

dotnet restore .\Lodgify.Property.sln
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services\Lodgify.Property.Services.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Models\Lodgify.Property.Models.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property\Lodgify.Property.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Tests.Integration\Lodgify.Property.Tests.Integration.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Domain\Lodgify.Property.Domain.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services.Abstractions\Lodgify.Property.Services.Abstractions.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Infrastructure\Lodgify.Property.Infrastructure.csproj...
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.API\Lodgify.Property.API.csproj...  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property\obj\Lodgify.Property.csproj.nuget.g.props.
  Restore completed in 582.89 ms for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property\Lodgify.Property.csproj.
  Restoring packages for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.API\Lodgify.Property.API.csproj...  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Domain\obj\Lodgify.Property.Domain.csproj.nuget.g.props.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Domain\obj\Lodgify.Property.Domain.csproj.nuget.g.targets.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services.Abstractions\obj\Lodgify.Property.Services.Abstractions.csproj.nuget.g.props.
  Restore completed in 1.22 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Domain\Lodgify.Property.Domain.csproj.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services.Abstractions\obj\Lodgify.Property.Services.Abstractions.csproj.nuget.g.targets.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Models\obj\Lodgify.Property.Models.csproj.nuget.g.props.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Models\obj\Lodgify.Property.Models.csproj.nuget.g.targets.
  Restore completed in 1.29 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Models\Lodgify.Property.Models.csproj.
  Restore completed in 1.28 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services.Abstractions\Lodgify.Property.Services.Abstractions.csproj.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Tests.Integration\obj\Lodgify.Property.Tests.Integration.csproj.nuget.g.props.
  Restore completed in 1.4 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Tests.Integration\Lodgify.Property.Tests.Integration.csproj.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Infrastructure\obj\Lodgify.Property.Infrastructure.csproj.nuget.g.props.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Infrastructure\obj\Lodgify.Property.Infrastructure.csproj.nuget.g.targets.
  Restore completed in 1.75 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Infrastructure\Lodgify.Property.Infrastructure.csproj.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services\obj\Lodgify.Property.Services.csproj.nuget.g.props.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services\obj\Lodgify.Property.Services.csproj.nuget.g.targets.
  Restore completed in 1.77 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.Services\Lodgify.Property.Services.csproj.
  Restore completed in 1.66 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.API\Lodgify.Property.API.csproj.
  Generating MSBuild file C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.API\obj\Lodgify.Property.API.csproj.nuget.g.props.
  Restore completed in 5.01 sec for C:\Projects\Logify\develop\lodgify-property\Lodgify.Property.API\Lodgify.Property.API.csproj.

Actual behavior

C:\Projects\Logify\develop\lodgify-property [property-api-wip ↓1 +2 ~3 -0 !]> docker-compose -f .\docker-compose.ci.build.yml up
Recreating lodgifyproperty_ci-build_1 ...
Recreating lodgifyproperty_ci-build_1 ... done
Attaching to lodgifyproperty_ci-build_1
ci-build_1  |   Restoring packages for /src/Lodgify.Property.API/Lodgify.Property.API.csproj...
ci-build_1  |   Restoring packages for /src/Lodgify.Property.Domain/Lodgify.Property.Domain.csproj...
ci-build_1  | /usr/share/dotnet/sdk/2.0.2/NuGet.targets(102,5): error : Unable to load the service index for source http://nuget.svc.codebay.es/nuget. [/src/Lodgify.Property.sln]
ci-build_1  | /usr/share/dotnet/sdk/2.0.2/NuGet.targets(102,5): error :   Response status code does not indicate success: 401 (Unauthorized). [/src/Lodgify.Property.sln]
lodgifyproperty_ci-build_1 exited with code 1

Additional information

Reproduced inside microsoft/aspnetcore-build linux image. Runs ok(see expected behaviour) when building on windows host with VS 2017 Community 15.3.

Output of dotnet --info

root@5e7324e41eaf:/src# dotnet --info
.NET Command Line Tools (2.0.2)

Product Information:
 Version:            2.0.2
 Commit SHA-1 hash:  a04b4bf512

Runtime Environment:
 OS Name:     debian
 OS Version:  8
 OS Platform: Linux
 RID:         debian.8-x64
 Base Path:   /usr/share/dotnet/sdk/2.0.2/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

Output of docker info

 docker info
Containers: 1
 Running: 1
 Paused: 0
 Stopped: 0
Images: 24
Server Version: 17.09.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 06b9cb35161009dcb7123345749fef02f7cea8e0
runc version: 3f2f8b84a77f73d38244dd690525642a72156c64
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.49-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: moby
ID: EAEE:DR3T:2JHD:C2VT:VX7T:SS4M:WS75:SXA4:K2DS:AHWZ:6TY7:SMHT
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 31
 Goroutines: 48
 System Time: 2017-10-18T17:39:30.3003966Z
 EventsListeners: 1
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
natemcmaster commented 7 years ago

Can you ensure the environment variable is set correctly? Try adding printenv before dotnet-restore.

netspark commented 7 years ago

Sure, @natemcmaster. Here is the output with printenv prepended:

docker-compose -f .\docker-compose.ci.build.yml up
Recreating lodgifyproperty_ci-build_1 ...
Recreating lodgifyproperty_ci-build_1 ... done
Attaching to lodgifyproperty_ci-build_1
ci-build_1  | NODE_VERSION=6.11.3
ci-build_1  | NuGetPackageSourceCredentials_lodgify=Username=MyUser;Password=MyPass
ci-build_1  | HOSTNAME=f91c81d5a72d
ci-build_1  | DOTNET_SDK_DOWNLOAD_SHA=1242E8B72911A868E4F6C5D1112A64AD094223FA146DF04058160D25FABD44E4D1C50D076F3655C91613D32BC43D0514D3BAC7C3D112C23A670B5DA3676076F8
ci-build_1  | NUGET_XMLDOC_MODE=skip
ci-build_1  | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ci-build_1  | PWD=/src
ci-build_1  | DOTNET_SDK_VERSION=2.0.2
ci-build_1  | ASPNETCORE_URLS=http://+:80
ci-build_1  | SHLVL=1
ci-build_1  | HOME=/root
ci-build_1  | DOTNET_SDK_DOWNLOAD_URL=https://dotnetcli.blob.core.windows.net/dotnet/Sdk/2.0.2/dotnet-sdk-2.0.2-linux-x64.tar.gz
ci-build_1  | ASPNETCORE_PKG_VERSION=2.0.0
ci-build_1  | _=/usr/bin/printenv
ci-build_1  |   Restoring packages for /src/Lodgify.Property.API/Lodgify.Property.API.csproj...
ci-build_1  |   Restoring packages for /src/Lodgify.Property.Domain/Lodgify.Property.Domain.csproj...
ci-build_1  | /usr/share/dotnet/sdk/2.0.2/NuGet.targets(102,5): error : Unable to load the service index for source http://nuget.svc.codebay.es/nuget. [/src/Lodgify.Property.sln]
ci-build_1  | /usr/share/dotnet/sdk/2.0.2/NuGet.targets(102,5): error :   Response status code does not indicate success: 401 (Unauthorized). [/src/Lodgify.Property.sln]
lodgifyproperty_ci-build_1 exited with code 1
natemcmaster commented 7 years ago

Hmm, I don't see anything wrong with the docker setup. This issue needs to move to https://github.com/NuGet/home. It looks like something in the NuGet client is not loading your credential correctly.

netspark commented 6 years ago

This issue needs to move to https://github.com/NuGet/home

Should I go there and create the issue? I am not very sure which versions of NuGet libraries SDK uses...

natemcmaster commented 6 years ago

Yes, open the issue there. Telling them you are using dotnet 2.0.2 should be enough info for them to identify which version of NuGet has the bug.

capearlman commented 6 years ago

@netspark Can you point me to the issue you created at https://github.com/NuGet/home?