ERROR: failed to calculate checksum of ref .csproj not found

This is my github actions yaml file content:

name: .NET

on:
  push:
    branches: [ "master" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
      
    - name: Build the Docker image
      working-directory: CICD-API
      run: docker build . -t jushstone/cicd-docker:latest

    - name: Log into Docker Hub
      uses: docker/login-action@v2
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_TOKEN }}

    - name: Push the image to Docker Hub
      run: docker push jushstone/cicd-docker

    - name: Pull the image to VM
      uses: appleboy/ssh-action@v1.0.0
      with:
        host: ${{ secrets.SSH_HOST }}
        username: ${{ secrets.SSH_USERNAME }}
        key: ${{ secrets.SSH_KEY }}
        script: 
          docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cicd-docker:latest
          docker stop cicd-docker || true
          docker rm cicd-docker || true
          docker run -d -p 80:80 --name cicd-docker ${{ secrets.DOCKERHUB_USERNAME }}/cicd-docker:latest

This is my dockerfile content:

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["CICD-API/CICD-API.csproj", "CICD-API/"]
COPY ["CICD-Core/CICD-Core.csproj", "CICD-Core/"]
RUN dotnet restore "./CICD-API/CICD-API.csproj"
COPY . .
WORKDIR "/src/CICD-API"
RUN dotnet build "./CICD-API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./CICD-API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "CICD-API.dll"]

I get an error when building the Docker image and in these two lines in dockerfile produce this error:

COPY ["CICD-API/CICD-API.csproj", "CICD-API/"]
COPY ["CICD-Core/CICD-Core.csproj", "CICD-Core/"]

It says that:

ERROR: failed to calculate checksum of ref 66cd06a6-b278-495c-ae3e-04e926acdc46::8a98uq2w3sytdrzki0tdwy8qq: "/CICD-API/CICD-API.csproj": not found
ERROR: failed to calculate checksum of ref 66cd06a6-b278-495c-ae3e-04e926acdc46::8a98uq2w3sytdrzki0tdwy8qq: "/CICD-Core/CICD-Core.csproj": not found

What is the problem? I think it is from the work directory path, but how can I fix it?

Copying your files into the right directory using absolute destination path instead of relative.
Or fixing the workdir itself. Depending on what your original goal was.


I edited your message to add code blocks. Please, format your posts next time according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Example code block:

```
echo "I am a code."
echo "An athletic one, and I wanna run."
```

1 Like

Thanks, Yes, I move the Dockerfile to the root directory (beside the project solution file) and change the working directory of build section in yaml file to the ${{ github.workspace }} and now it is working.