3

I am using .net 6.0 SDK with my project referring to my company's nuget package source and am copying the local nuget.config file to project location in docker file, but my restore fails randomly in on docker build in gitlab but works fine locally.

Random Error which is not helpful at all:

build FAILED.
       "/src/microservice-fleet-access-api/microservice-fleet-access-api.csproj"
(Restore target) (1) ->
       (Restore target) -> 
         /usr/share/dotnet/sdk/6.0.400/NuGet.targets(132,5): error MSB4181: The "RestoreTask" task returned false but did not log an
error.
[/src/microservice-fleet-access-api/microservice-fleet-access-api.csproj]`

Docker file:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["myProject.csproj", "myProject/"]
COPY ["nuget.config", "myProject/nuget.config"]
RUN dotnet restore "myProject/myProject.csproj"
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
  • running the dotnet restore command with verbosity helps at times flag `--verbosity`, first I would first just clear the cache of the nuget packages with `dotnet nuget locals all --clear` then run `dotnet restore` gitlab maybe working as it pulling a new image everytime it builds. – exception_thrown Aug 31 '22 at 00:33
  • 1
    I have the clearing the nuget and also enabled verbosity to detail but there is nothing help, it just fails randomly sometimes. Thanks PHPNoob – Manideep Kothapalli Aug 31 '22 at 15:17

0 Answers0