Home > Enterprise >  Azure App Service deployment Github Actions: Error: Deployment Failed with Error: Error: No package
Azure App Service deployment Github Actions: Error: Deployment Failed with Error: Error: No package

Time:11-28

I have a dotnet core app I am trying to deploy to Azure with GitHub actions CI/CD. However, the app is not on root repository but rather inside of another folder MYAPP. So I had to update working-directory of build and publish jobs but now I keep getting this error:

Run azure/webapps-deploy@v2 Error: Deployment Failed with Error: Error: No package found with specified pattern: ./published

My project structure is as such

├── .github/workflows                   
├── MYAPP  
├───── MYAPP.sln
├───── MYAPPTESTS   
├───── MYAPP
├─────────── MYAPP.csproj   
├── docs                    
├── OtherFolder                 
└── README.md

My YML file is as below

name: Build and deploy ASP.Net Core app to Azure Web App - myappdeploy

on:
  push:
    branches:
      - main
  workflow_dispatch:

env:
  AZURE_WEBAPP_PACKAGE_PATH: './published'   

jobs:
  build:
    runs-on: windows-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up .NET Core
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: '6.0.x'
          include-prerelease: true
          
      - name: dotnet build and publish
        working-directory: ./MYAPP
        run: |
          dotnet restore
          dotnet build --configuration Release
          dotnet publish -c Release -o ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
          
      - name: 'Run Azure webapp deploy action using publish profile credentials'
        uses: azure/webapps-deploy@v2
        with: 
            app-name: 'myappdeploy'
            publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_7894EB5E4C174F72A5EDE9C64B658907 }}
            package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

What am I missing? Thanks

Instead of working directory I have tried adding .deployment to root repository.

[config]
project = ./MYAPP

However this file was not read and the pipeline would say that it can't find .sln file. I have also tried adding Project app setting on Azure App Service configuration but still the pipeline would not work.

I have tried removing the package parameter of the azure/webapps-deploy@v2 and the pipeline runs successfully however I instead get the error when accessing the website:

You do not have permission to view this directory or page

Also, none of the routes of my app can be found (404)

When running the solution locally there are no issues.. and when deploying manually to an app service through Visual Studio GUI there are also no issues. However, this is not a proper solution as GitHub CI/CD is needed.

CodePudding user response:

For anyone who might come into the same issue, I had to specify where the .sln is during dotnet build and where the .csproj is for dotnet publish. Also remove working-directory

      - name: dotnet build and publish
        # working-directory: ./MYAPP
        run: |
          dotnet restore
          dotnet build MYAPP/MYAPP.sln --configuration Release
          dotnet publish MYAPP/MYAPP/MYAPP.csproj -c Release -o ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
  • Related