I am working on a GitLab CI/CD project to build a NET6 application into a docker image, which is pushed to AWS ECR. My issue is manifested in the continuous failure of 'COPY . .' or any other command after 'restore' of my targeted project.
Repo structure:
repo root
- projectFolder
- projectAPI
- projectAPI.csproj
- DockerFile
- nuget.config
- referencedClassLibrary1
- referencedClassLibrary2
- .sln
- gitlab-ci.yml
- package.json
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
EXPOSE 80
WORKDIR /app
ARG Nuget_CustomFeedUserName
ARG Nuget_CustomFeedPassword
COPY "TT.CS/TT.CS.API/nuget.config" ""
COPY "TT.CS/TT.CS.DAL/TT.CS.DAL.csproj" "TT.CS.DAL/"
COPY "TT.CS/TT.CS.BLL/TT.CS.BLL.csproj" "TT.CS.BLL/"
COPY "TT.CS/TT.CS.API/TT.CS.ConfigAPI.csproj" "TT.CS.API/"
RUN ls -al
RUN sed -i "s|</configuration>|<packageSourceCredentials><aws><add key=\"Username\" value=\"${Nuget_CustomFeedUserName}\" /><add key=\"ClearTextPassword\" value=\"${Nuget_CustomFeedPassword}\" /></aws></packageSourceCredentials></configuration>|" /app/nuget.config
RUN dotnet restore --configfile "/app/nuget.config" "TT.CS.API/TT.CS.ConfigAPI.csproj"
COPY . .
WORKDIR "/app/TT.CS.API"
RUN dotnet publish --no-restore -c Release -o /app/out "TT.CS.ConfigAPI.csproj"
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "TT.CS.ConfigAPI.dll"]
Outcome:
#17 3.891 Restored /app/TT.CS.BLL/TT.CS.BLL.csproj (in 1.58 sec).
#17 3.891 Restored /app/TT.CS.DAL/TT.CS.DAL.csproj (in 1.58 sec).
#17 3.941 Restored /app/TT.CS.API/TT.CS.ConfigAPI.csproj (in 1.67 sec).
#17 DONE 4.1s
#18 [build-env 11/14] COPY . .
#18 sha256:23c9d357832b3a7c1a8c5d607316f97c2fa09b51818f473a97f709f9cfeb981f
#18 ERROR: failed to prepare i2owcagafc3j7shg0slffonae: invalid argument
------
> [build-env 11/14] COPY . .:
------
failed to prepare i2owcagafc3j7shg0slffonae: invalid argument
I've created a solution with a single folder sln/csproj without referencing the same solution projects, which works as expected but I'm still having issues with more complex solutions that combine multiple referenced projects with public and private nuget repos. Does anyone see some obvious mistake? Thanks