I've a simple gRpc application, classic HelloWorld which comes along with an operation SayHello. I added in this project a reference to a nuget package stored in our corporate feed (let's call the source hereafter https://my_corporate_feed/nuget/v3/index.json).
Then I added the Docker support to my project using the functionality provided by VisualStudio 2022 and I get this Dockerfile generated for me
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["nuget.config", "."]
COPY ["Greteer/Greteer.csproj", "Greteer/"]
RUN dotnet restore "Greteer/Greteer.csproj"
COPY . .
WORKDIR "/src/Greteer"
RUN dotnet build "Greteer.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Greteer.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Greteer.dll"]
Nothing complicated so far. But, when I try to build and publish this docker file, I got an error during the RestoreTask. The error reports: error NU1301: Unable to load the service index for source https://my_corporate_feed/nuget/v3/index.json I've followed already some suggestions from SO users (ex. set dns for the docker daemon to [8.8.8.8]) but nothing works. I don't think that is a problem of connectivity because the normal packages (gRpc and Microsoft.Data.SqlClient) are restored correctly. I think the problem is just my feed source. Has anyone of use face similar issue? Thanks
As you confirmed, this issue needs you to pass credentials like PAT token into the dockerfile, otherwise it will be impossible to access the feed.
By the way, this type of issue always have secondary error output, you can use fiddler to capture the network trace. In this way, you will get the actual cause of the issue.