Reputation: 81
I'm setting up a buid in Azure DevOps with a Docker Image and have some problems. My docker build command doesn't work in local and in Azure DevOps build machine. In local the command throws this error :
C:\Program Files\dotnet\sdk\2.2.401\NuGet.targets(123,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\app\src\WebApi\WebApi.csproj]
C:\Program Files\dotnet\sdk\2.2.401\NuGet.targets(123,5): error : No such host is known [C:\app\src\WebApi\WebApi.csproj]
The command 'cmd /S /C dotnet restore src/WebApi/WebApi.csproj' returned a non-zero code: 1
And in Azure DevOps this error :
C:\Program Files\dotnet\sdk\2.2.401\NuGet.targets(123,5): error : Access to the path 'C:\app\src\Bll\obj\Bll.csproj.nuget.g.props' is denied. [C:\app\src\WebApi\WebApi.csproj]
The command 'cmd /S /C dotnet restore src/WebApi/WebApi.csproj' returned a non-zero code: 1
##[error]The process 'C:\Program Files\Docker\docker.exe' failed with exit code 1
I tried to restart the Docker service and turn off automatic windows proxy configuration. The problem was on my local machine, it was not able to reach the url. So, I tried to build my dockerfile in Azure DevOps. And I don't understand why the restore step fails too with permission error. I searched for solutions on Google, but didn't find any.
My dockerfile :
# STAGE01 - Build application and its dependencies
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
COPY src/**/*.csproj ./
COPY . ./
RUN dotnet restore .\Authentication.sln
# STAGE02 - Publish the application
FROM build-env AS publish
RUN dotnet publish -c Release -o /app
# STAGE03 - Create the final image
FROM microsoft/dotnet:2.2.0-aspnetcore-runtime
WORKDIR /app
LABEL Author="Tango"
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "WebApi.dll", "--server.urls", "http://*:80"]
Solution folder structure:
.sln dockerfile src / -- Dal / ---- Dal.csproj -- Bll / ---- Bll.csproj -- WebApi / ---- WebApi.csproj
What am I missing?
Upvotes: 5
Views: 5698