question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dotnet restore fails to use the local Nuget.Config to retrieve nuget packages from private feeds while building docker image

See original GitHub issue

Steps 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:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
robisonkarlscommented, Feb 21, 2018

I had the same problem and I did something similar,

COPY NuGet.Config /root/.nuget/NuGet/

8reactions
jim-at-survey-comcommented, Jul 18, 2019

I had the same issue but my file was capitalized “Nuget.confg” originally and changing it to “NuGet.Config” appears to have worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotnet restore fails to use the local Nuget.Config to retrieve ...
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 ......
Read more >
dotnet restore in docker build not using all nuget sources ...
1 Answer. At the time you do dotnet restore in your Dockerfile, the nuget. config file hasen't been copied into the image. You've...
Read more >
Restore NuGet Packages from a Private Feed when ...
The first step to restoring the NuGet package from the private feed is to add a nuget.config file to the root folder of...
Read more >
Restore Nuget Packages inside a Docker Container
Restoring Nuget packages from private feeds can be tricky. Use a nuget.config file with the URLs to all Nuget feeds and add the...
Read more >
Consuming private NuGet feeds from Dockerfile - DevOps.dev
To be able to restore your private packages from a Dockerfile all you need to do is make sure that Nuget.config gets copied,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found