skip to Main Content

I’m working on a project that uses a .NET Core backend and an Angular frontend, and I’m deploying it to Azure using a GitHub Actions workflow. I’ve created a workflow that checks out both the backend and frontend repositories. I build the Angular project and move its output to the wwwroot folder in the .NET backend.

Key parts of my workflow:

# Step 6: Install Angular dependencies and build the Angular app
- name: Install dependencies and build Angular app
  run: |
    cd frontend
    npm ci --legacy-peer-deps
    npx ng build --configuration=production --output-path="./angular-output" --output-hashing=all

# Step 7: List the Angular build output to verify contents
- name: List Angular build output
  run: ls -R ./frontend/angular-output

# Step 8: Move Angular build output to .NET wwwroot
- name: Move Angular build output to .NET wwwroot
  run: mv ./frontend/angular-output/* ./Main/Applications/Lili.Shop.API/wwwroot/

# Step 9: List the wwwroot contents after moving files to verify placement
- name: List wwwroot contents after moving Angular files
  run: ls -R ./Main/Applications/Lili.Shop.API/wwwroot

When I check the angular-output folder, the assets folder exists and contains the expected files. However, after running the mv command to move everything to the wwwroot folder, only the index.html and other Angular files are there – the assets folder and its contents are missing.

I’ve tried:

  • Moving the assets folder separately in an additional step, but that didn’t resolve the issue.
  • Logging the directory contents before and after the move, which shows that the assets folder is present in angular-output but doesn’t appear in the destination folder after the move.

Why might the assets folder be missing after the move operation? Could this be a permissions issue or something related to how GitHub Actions handles the move command? Is there a better way to ensure that all Angular build output, including the assets folder, is properly moved to the wwwroot folder in the .NET project?

2

Answers


  1. Chosen as BEST ANSWER

    @Delta: Thank you! Your solution is simple and perfect. I wasn't aware of this option. I also came up with an alternative solution:

    Move Angular build output to .NET wwwroot:

    - name: Move Angular build output to .NET wwwroot
      run: |
        if (!(Test-Path ./Main/Applications/Lili.Shop.API/wwwroot/assets)) {
          New-Item -ItemType Directory -Path ./Main/Applications/Lili.Shop.API/wwwroot/assets
        }
    
        Copy-Item ./frontend/angular-output/assets/* ./Main/Applications/Lili.Shop.API/wwwroot/assets/ -Recurse -Force
    
        Copy-Item ./frontend/angular-output/* ./Main/Applications/Lili.Shop.API/wwwroot/ -Recurse -Forc
    
        Remove-Item ./frontend/angular-output -Recurse -Force
      shell: pwsh
    

  2. Why can’t you use this?

    --output-path=../Main/Applications/Lili.Shop.API/wwwroot
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search