Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to see my Private Server inside NuGet.Config file with docker #6581

Closed
RamazanBIYIK opened this issue Feb 19, 2018 · 13 comments
Closed

Comments

@RamazanBIYIK
Copy link

I have ASP.Net Core 2.0 project and ı am using packages from nuget.org and My Private Server. I succesfully launch my API with visual studio. But when issue come to docker it gets complicated. It was not seeing my private server at the beginning because of NuGet.Config file was absend inside project directory. This time nuget see only 1 of sources(Nuget.org or my private server).

NuGet product used :

Package manager Console , dotnet.exe , NuGet.exe, Docker

NuGet version (x.x.x.xxx):

v4.5.1

VS version (if appropriate):
VS 17
OS version (i.e. win10 v1607 (14393.321)):
Win 10

1.My NuGet.Config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
	 </packageSources>
	<packageSources>
    <add key="MyPrivate" value="http://nugetserver.azurewebsites.net/nuget/Packages" />
  </packageSources>

  <apikeys>
    <add key="https://www.nuget.org" value="Some_Long_Value" />
 
  </apikeys>
  <disabledPackageSources />
</configuration>

2.My Dockerfile

FROM microsoft/aspnetcore-build:2.0 AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers and NuGet.Config
COPY *.csproj ./
COPY NuGet.Config /root/.nuget/NuGet/NuGet.Config

# Copy everything else and build
COPY . ./
RUN dotnet restore

RUN dotnet publish -c Release -o out

# Build runtime image
FROM microsoft/aspnetcore:2.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "MyProject.dll"]

I wrote the problem here because i think Docker can see my NuGet.Config file but not servers due to inappropriation inside NuGet.Config file. When ı type docker build -t webserv . the error pops up at Dockerfile's dotnet restore command.

MyProject.csproj : error NU1101: Unable to find packageWebApi.Utils. No packages exist with this id in source(s): nuget.org

If i add a source to NuGet.Config under "addkey" tag

add key="http://nugetserver.azurewebsites.net/nuget" value="ApiKey" /

This time ı have this error for every package inside my project:

Retrying 'FindPackagesByIdAsyncCore' for source 'http://nugetserver.azurewebsites.net/nuget/Packages/FindPackagesById()?id='SwaggerUi''.
Response status code does not indicate success: 404 (Not Found).
C:\Program Files\dotnet\sdk\2.1.4\NuGet.targets(103,5): error : Failed to retrieve information about 'Microsoft.VisualStudio.Web.CodeGeneration.Design' from remote source 'http://nugetserver.azurewebsites.net/nuget/Packages/FindPackagesById()?id='Microsoft.VisualStudio.Web.CodeGeneration.Design''. [C:\app\MyProject.csproj]
C:\Program Files\dotnet\sdk\2.1.4\NuGet.targets(103,5): error : Response status code does not indicate success: 404 (Not Found). [C:\app\MyProject.csproj]
The command 'cmd /S /C dotnet restore' returned a non-zero code: 1

As you can see at the NuGet.Config ı have 2 source but it says i have only one source. If ı can build and run my project with VS 17 then ı think my NuGet.Config file is correct but with Docker Commands it doesn't. Is nuget incompatible with docker or my settings are wrong. That blows my mind. Plase help.

@RamazanBIYIK
Copy link
Author

Ok i figure it out. My NuGet.Config file was wrong. When ı delete

<apikeys>
    <add key="https://www.nuget.org" value="Some_Long_Value" />
 </apikeys>

that it worked.

@venmaram
Copy link

same error. can anyone help on this issue? Thanks

@niraj-bpsoftware
Copy link

same error

@hugonavak
Copy link

Same error.

@testpbb
Copy link

testpbb commented May 20, 2019

same error.

@lintakumar
Copy link

same error..Pls help

@eaaguirren
Copy link

same error pls

@lintakumar
Copy link

lintakumar commented Feb 10, 2020

My Nuget config -

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <!-- Allow NuGet to download missing packages -->
    <add key="enabled" value="True" />
    <!-- Automatically check for missing packages during build in Visual Studio -->
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="GlobalInternalFeed" value="http://test.global.com/NugetFeed/nuget"/>    
  </packageSources>
</configuration>

Docker File has this -
RUN dotnet restore "Persistence.EntityFramework/Persistence.EntityFramework.csproj" --configfile "Persistence.EntityFramework/Nuget.config"
This worked for me

@yonahochieng
Copy link

Using the IP address of the private repo instead of the server name sorted out the problem for me.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
    <add key="CreditQuestAPIPackage" value="http://**10.XX.254.XX**:1211/nuget" />
  </packageSources>
  <packageRestore>
    <add key="enabled" value="True" />
    <add key="automatic" value="True" />
  </packageRestore>
</configuration>

@yonahochieng
Copy link

My Nuget config -

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageRestore>
    <!-- Allow NuGet to download missing packages -->
    <add key="enabled" value="True" />
    <!-- Automatically check for missing packages during build in Visual Studio -->
    <add key="automatic" value="True" />
  </packageRestore>
  <packageSources>
    <add key="NuGet.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="GlobalInternalFeed" value="http://test.global.com/NugetFeed/nuget"/>    
  </packageSources>
</configuration>

Docker File has this -
RUN dotnet restore "Persistence.EntityFramework/Persistence.EntityFramework.csproj" --configfile "Persistence.EntityFramework/Nuget.config"
This worked for me

Change test.global.com to IP

@VGerris
Copy link

VGerris commented Jun 29, 2020

Why on earth is this closed? How about DNS resolution is made to work, like it does for all other command I use like ping?
Please reopen this issue and address the issue if that is actually the problem.
I had this issue on Ubuntu Linux at initial run and continuously in docker.

Related seem:
dotnet/sdk#8299
#6140

@SP-SuperPoney
Copy link

Same problem here !

@hippieZhou
Copy link

I have the same issue and fix it with this docs: Managing NuGet Credentials in Docker Scenarios

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests