Search code examples
azure-devopsazure-pipelinesazure-static-web-app

Task AzureStaticWebApp@0 'could not detect this directory' but its presented


I am working on building a pipeline using AzureDevOps, and I face a strange problem.

This is my pipeline:

- stage: 'Test'
  displayName: 'Deploy to the test environment'
  dependsOn: Build
  jobs:
    - job: 'Deploy'
      steps:
      - download: current
        artifact: lorehub-front
      - bash: cd $(Pipeline.Workspace); echo $(ls)
      - bash: cd $(Pipeline.Workspace)/lorehub-front; echo $(ls)
      - task: AzureStaticWebApp@0
        displayName: 'Publish to Azure Static WebApp'
        inputs:
          app_location: $(Pipeline.Workspace)/lorehub-front
          azure_static_web_apps_api_token: xxxx

The first bash shows that the folder 'lorehub-front' is presented

The second bash shows that the inside folder is correct files (index.html and etc)

Script contents: cd /home/vsts/work/1/lorehub-front; echo $(ls)

android-chrome-192x192.png android-chrome-512x512.png apple-touch-icon.png css env-config.js favicon-16x16.png favicon-32x32.png favicon.ico fonts index.html js site.webmanifest

But I am receiving this error:

App Directory Location: '/home/vsts/work/1/lorehub-front' is invalid. Could not detect this directory. Please verify your deployment configuration file reflects your repository structure.


Solution

  • App Directory Location: '/home/vsts/work/1/lorehub-front' is invalid.

    The method to resolve this issue is that you need to change the path to /lorehub-front.

      - task: AzureStaticWebApp@0
        displayName: 'Publish to Azure Static WebApp'
        inputs:
          app_location: /lorehub-front
          azure_static_web_apps_api_token: xxxx
    

    For more detailed info, you could refer to this doc: Tutorial: Publish Azure Static Web Apps with Azure DevOps

    Enter / if your application source code is at the root of the repository, or /app if your application code is in a directory called app.