After going through or referring through alot of documentation and SO threads or in this forum on using Nuget.config file to restore build process; i give up and here asking for help.
>docker info
Client:
Version: 24.0.6
Context: default
Debug Mode: false
My Docker file:
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS buildPhase
ARG BUILD_CONFIGURATION=Release
ARG ARTIFACTORY__API_KEY=%ARTIFACTORY__API_KEY%
ARG ARTIFACTORY__USER=%ARTIFACTORY__USER%
WORKDIR /src
COPY ["MyProj/MyProj.csproj", "MyProj/"]
COPY ./Nuget.config /src
RUN dotnet restore "./MyProj/MyProj.csproj" --configfile /src/Nuget.config
My Nuget.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="dev" value="https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget" />
</packageSources>
<packageSourceCredentials>
<dev>
<add key="Username" value="%ARTIFACTORY__USER%" />
<add key="ClearTextPassword" value="%ARTIFACTORY__API_KEY%" />
</dev>
</packageSourceCredentials>
<packageSourceMapping>
<packageSource key="dev">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
With above configuration; i am trying to set the environment variables for Nuget feed by following this article: dotnet-docker/documentation/scenarios/nuget-credentials.md at main · dotnet/dotnet-docker · GitHub
No matter what i try (powershell/cmd) i am unable to get the restore phase success in dockerfile.
Below are the commands i am issuing:
> $env:ARTIFACTORY__USER = 'user@user.com'
> $env:ARTIFACTORY__API_KEY = 'apikey'
> docker build --build-arg $env:ARTIFACTORY__API_KEY --build-arg $env:ARTIFACTORY__USER -f .\Custom.Dockerfile .
Errors i get are and docker build output:
Sending build context to Docker daemon 450kB
Step 1/20 : FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS buildSicamLicenseSigner
---> 6232c212dfa2
Step 2/20 : ARG BUILD_CONFIGURATION=Release
---> Using cache
---> 03d673382ea5
Step 3/20 : ARG ARTIFACTORY__API_KEY=%ARTIFACTORY__API_KEY%
---> Using cache
---> b9a5202d2492
Step 4/20 : ARG ARTIFACTORY__USER=%ARTIFACTORY__USER%
---> Using cache
---> 24026604c95e
Step 5/20 : WORKDIR /src
---> Using cache
---> 3026cc959337
Step 6/20 : COPY ["MyProj/MyProj.csproj", "MyProj/"]
---> Using cache
---> e4fc943fcd7e
Step 7/20 : COPY ./Nuget.config /src
---> Using cache
---> b797e8f1b9fd
Step 8/20 : RUN dotnet restore "./MyProj/MyProj.csproj" --configfile /src/Nuget.config
---> Running in 0f70aa322b50
C:\Program Files\dotnet\sdk\8.0.101\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files\dotnet\sdk\8.0.101\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "C:\src\MyProj\MyProj.csproj (85,2)". This is most likely a build authoring error. This subsequent import will be ignored.
C:\Program Files\dotnet\sdk\8.0.101\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(37,3): warning MSB4011: "C:\Program Files\dotnet\sdk\8.0.101\Microsoft.CSharp.targets" cannot be imported again. It was already imported at "C:\src\MyProj\MyProj.csproj (85,2)". This is most likely a build authoring error. This subsequent import will be ignored.
Determining projects to restore...
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='CommandLineParser'&semVerLevel=2.0.0'.
Response status code does not indicate success: 401.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.Configuration'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.DependencyModel'&semVerLevel=2.0.0'.
Response status code does not indicate success: 401.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='ServerClient'&semVerLevel=2.0.0'.
Response status code does not indicate success: 401.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog.Settings.Configuration'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog.Sinks.File'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.Configuration.Json'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.Configuration'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='ServerClient'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.DependencyModel'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='CommandLineParser'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog.Settings.Configuration'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.Configuration.Json'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog.Sinks.File'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
Retrying 'FindPackagesByIdAsyncCore' for source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog'&semVerLevel=2.0.0'.
Response status code does not indicate success: 403.
C:\src\MyProj\MyProj.csproj : error NU1301: Failed to retrieve information about 'ServerClient' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='ServerClient'&semVerLevel=2.0.0'.
C:\src\MyProj\MyProj.csproj : error NU1301: Failed to retrieve information about 'Microsoft.Extensions.Configuration' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.Configuration'&semVerLevel=2.0.0'.
C:\src\MyProj\MyProj.csproj : error NU1301: Failed to retrieve information about 'Serilog.Settings.Configuration' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog.Settings.Configuration'&semVerLevel=2.0.0'.
C:\src\MyProj\MyProj.csproj : error NU1301: Failed to retrieve information about 'CommandLineParser' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='CommandLineParser'&semVerLevel=2.0.0'.
C:\src\MyProj\MyProj.csproj : error NU1301: Failed to retrieve information about 'Microsoft.Extensions.DependencyModel' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.DependencyModel'&semVerLevel=2.0.0'.
C:\src\MyProj/MyProj.csproj : error NU1301: Failed to retrieve information about 'Microsoft.Extensions.Configuration.Json' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Microsoft.Extensions.Configuration.Json'&semVerLevel=2.0.0'.
C:\src\MyProj/MyProj.csproj : error NU1301: Failed to retrieve information about 'Serilog.Sinks.File' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog.Sinks.File'&semVerLevel=2.0.0'.
C:\src\MyProj/MyProj.csproj : error NU1301: Failed to retrieve information about 'Serilog' from remote source 'https://xyz.jfrog.io/artifactory/api/nuget/v3/dev-nuget/FindPackagesById()?id='Serilog'&semVerLevel=2.0.0'.
Failed to restore C:\src\MyProj\MyProj.csproj (in 4.98 sec).
The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; dotnet restore "./MyProj/MyProj.csproj" --configfile /src/Nuget.config' returned a non-zero code: 1
As you can see; the host is reachable from the container; its just that it can not authenticate.
Kindly please help.
Thanks