Dotnet restore fails to use the local Nuget.Config to retrieve nuget packages from private feeds while building docker image
See original GitHub issueSteps to reproduce
add a Nuget.Config to your project with a private feed and run dotnet restore as part of docker build. Below is the basic Docker file that I am using.
FROM microsoft/dotnet:latest
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 80
CMD ["dotnet", "run", "--server.urls", "http://*:80"]
Dotnet restore fails because it is not using the package sources from the nuget.config file inside the project. Below is the Nuget.Config file that I am using (mocking the private feed name).
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear/>
<add key="private package source" value="http://artifactory.private.svc/artifactory/api/nuget/nuget-release-local" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
Expected behavior
NuGet Config files used: /root/appName/Nuget.Config /root/.nuget/NuGet/NuGet.Config
Feeds used: http://artifactory.private.svc/artifactory/api/nuget/nuget-release-local https://api.nuget.org/v3/index.json
Actual behavior
NuGet Config files used: /root/.nuget/NuGet/NuGet.Config
Feeds used: https://api.nuget.org/v3/index.json
Environment data
dotnet --info output:
dotnet --info .NET Command Line Tools (1.0.1)
Product Information: Version: 1.0.1 Commit SHA-1 hash: 005db40cd1
Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64 Base Path: /usr/share/dotnet/sdk/1.0.1
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:16 (1 by maintainers)

Top Related StackOverflow Question
I had the same problem and I did something similar,
COPY NuGet.Config /root/.nuget/NuGet/I had the same issue but my file was capitalized “Nuget.confg” originally and changing it to “NuGet.Config” appears to have worked.