Search code examples
azureblazor.net-6.0azure-static-web-app

Blazor Azure deployment error: "Error: Could not detect the language from repo."


I am trying to deploy Blazor .NET 6 app to Azure Static Web App. The problem is when I set up the build it crashes with:

Error: Could not detect the language from repo.

My deployment config:

name: Azure Static Web Apps CI/CD

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - main

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_MEADOW }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "PortfolioWeb" # App source code path
          api_location: "" # Api source code path - optional
          output_location: "wwwroot" # Built app content directory - optional
          ###### End of Repository/Build Configurations ######

  close_pull_request_job:
    if: github.event_name == 'pull_request' && github.event.action == 'closed'
    runs-on: ubuntu-latest
    name: Close Pull Request Job
    steps:
      - name: Close Pull Request
        id: closepullrequest
        uses: Azure/static-web-apps-deploy@v1
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_GENTLE_MEADOW_000314403 }}
          action: "close"

And my project structure:

PortfolioWeb [repository]
├── .git
├── .github
├── PortfolioWeb [solution dir]
│   ├── .vs
│   ├── PortfolioWeb [project dir]
│   │   └── <blazor project files>
│   └── PortfolioWeb.sln
├── README.md
│   ├── default.html
│   └── post.html
└── .gitignore

Did I mess up something in my paths ?

app_location: "PortfolioWeb"
api_location: ""
output_location: "wwwroot"

In many tutorials they did nothing else than this setup, specifying src folder and wwwroot. So why doesn't it work also in my case?


Solution

  • I found that I have to specify my project's (not solution's) relative path from the repository. So when I am in PortfolioWeb the app_location is:

    app_location: "PortfolioWeb/PortfolioWeb"
    

    so in other words

    app_location: "<SolutionFolder>/<ProjectFolder>"
    

    and after that my Azure Static Web App is successfully deployed and working.

    Documentation: https://learn.microsoft.com/sl-si/azure/static-web-apps/build-configuration?WT.mc_id=DOP-MVP-4020672&tabs=github-actions