Docker Community Forums

Share and learn in the Docker community.

Unable to restore package in Windows Server 2016

Expected behavior

It should work without any error

Actual behavior

C:\sampleSVC\WebApplication1>docker build -t webapplication1:latest .
Sending build context to Docker daemon 20.99kB
Step 1/17 : FROM aspnet:2.2-nanoserver-sac2016 AS base
—> f74b3b568bbc
Step 2/17 : WORKDIR /app
—> Using cache
—> 7c9d92f0ce8a
Step 3/17 : EXPOSE 80
—> Using cache
—> 2257bd59cd34
Step 4/17 : EXPOSE 443
—> Using cache
—> 214f17dc4a2a
Step 5/17 : FROM sdk:2.2-nanoserver-sac2016 AS build
—> 9773d80bdd64
Step 6/17 : WORKDIR /sampleSVC/WebApplication1
—> Using cache
—> b4c90013962a
Step 7/17 : COPY [“WebApplication1/WebApplication1.csproj”, “WebApplication1/”]
—> Using cache
—> 55425a946187
Step 8/17 : RUN dotnet restore “WebApplication1”
—> Running in f649cf051ecd
Restoring packages for C:\sampleSVC\WebApplication1\WebApplication1\WebApplication1.csproj…
C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : Unable to load the service index for source [C:\sampleSVC\WebApplication1\WebApplication1\WebApplication1.csproj]
C:\Program Files\dotnet\sdk\2.2.104\NuGet.targets(114,5): error : No such host is known [C:\sampleSVC\WebApplication1\WebApplication1\WebApplication1.csproj]
The command ‘powershell -Command $ErrorActionPreference = ‘Stop’; $ProgressPreference = ‘SilentlyContinue’; dotnet restore “WebApplication1”’ returned a non-zero code: 1


Steps to reproduce the behavior

  1. Development Env : Windows Server 2016 Server and VS 2019
    2.Create normal ASP.NET Core 2.2 Web application
    3.PFB Post for Docker file.
    4.Open command prompt and navigate to .sln and docker file location
  2. Execute this command docker build -t webapplication1:latest .

Can any provide solution for this

#Docker File Content
FROM AS base

FROM AS build
WORKDIR /sampleSVC/WebApplication1
COPY [“WebApplication1/WebApplication1.csproj”, “WebApplication1/”]

RUN dotnet restore “WebApplication1/WebApplication1.csproj”
#-p:RestoreUseSkipNonexistentTargets=false -nowarn:msb3202,nu1503
COPY . .
WORKDIR “/sampleSVC/WebApplication1”
RUN dotnet build “WebApplication1.csproj” -c Release -o /app

FROM build AS publish
RUN dotnet publish “WebApplication1.csproj” -c Release -o /app

FROM base AS final
COPY --from=publish /app .
ENTRYPOINT [“dotnet”, “WebApplication1.dll”]