Replies: 2 comments 2 replies
-
One thing you could try to help pinpoint the issue is to print the content of your NuGet.config file after running |
Beta Was this translation helpful? Give feedback.
-
I'm currently having the same problem when trying to build images that need a private repository, running "dotnet publish". I tried to:
All these attempts were made without using any replacement or valorization of the credentials. Running "dotnet restore" before "dotnet publish" doesn't change anything other than encountering in the previous (restore) command. The NuGet.Config file was working when using Visual Studio 2022 and it was correctly recognized to install the packages. These errors began to appear when trying to run the build in Jenkins, using the 8.0 SDK image to build the projects. When searching for the packages to be restores, nuget only searches in the public repositories (nuget.org, https://nuget.ors.it/NuGet/nuget) but never in the private ones. |
Beta Was this translation helpful? Give feedback.
-
I have a dockerfile which uses a private Nuget feed to restore packages using the .Net 7 sdk image. I am able to run this using Docker Desktop and through our local Azure Devops pipeline without issues. By only changing to the .Net 8 sdk image, it now fails when doing the restore with the following error "error NU1301: Unable to load the service index for source https://tfs.example.com/tfs/Default/_packaging/nuget/v3/index.json." I've tried several other ways based on this link https://github.com/dotnet/dotnet-docker/blob/main/documentation/scenarios/nuget-credentials.md including using Azure Artifact Credential Provider without success. What has changed in the .Net 8 images that this no longer works? The PAT is passed in through an environment variable.
old dockerfile
`
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /app
ARG PAT
COPY . ./
WORKDIR /app/myApp.Api
RUN dotnet nuget update source myFeed --valid-authentication-types basic --username "docker" --password "${PAT}" --store-password-in-clear-text
RUN dotnet restore
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS runtime
WORKDIR /app
COPY --from=build /app/myApp.Api/out ./
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN apt-get update && apt-get -y install gss-ntlmssp
ENTRYPOINT ["dotnet", "myApp.Api.dll"]
`
new dockerfile
`
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
ARG PAT
COPY . ./
WORKDIR /app/myApp.Api
RUN dotnet nuget update source myFeed --valid-authentication-types basic --username "docker" --password "${PAT}" --store-password-in-clear-text
RUN dotnet restore
RUN dotnet publish -c Release -o out
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
WORKDIR /app
COPY --from=build /app/myApp.Api/out ./
RUN sed -i 's/DEFAULT@SECLEVEL=2/DEFAULT@SECLEVEL=1/g' /etc/ssl/openssl.cnf
RUN apt-get update && apt-get -y install gss-ntlmssp
ENTRYPOINT ["dotnet", "myApp.Api.dll"]
`
NuGet.config
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="myFeed" value="https://tfs.example.com/tfs/Default/_packaging/nuget/v3/index.json" /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> </packageSources> </configuration>
Beta Was this translation helpful? Give feedback.
All reactions