GitHub actions fails publishing to Azure

Viewed 795

I'm trying to build and deploy ASP.NET Web application using GitHub actions and Azure.

I've successfully created and published to Azure a small app (.NET 4.8) using VS2017.

Now I'm trying to setup automatic deployment and I'm using the basic GitHub actions workflow that you get from Azure when setting up deployment.

When running the action I get into this error:

D:\a\pathtomyproject\myprojectname.csproj : error MSB4057: The target "pipelinePreDeployCopyAllFilesToOneFolder" does not exist in the project.

Here's the full action:

name: Build and deploy ASP app to Azure Web App 

on:
  push:
    branches:
      - develop
  workflow_dispatch:

jobs:
  build-and-deploy:
    runs-on: 'windows-latest'

    steps:
    - uses: actions/checkout@master

    - name: Setup MSBuild path
      uses: microsoft/setup-msbuild@v1.0.2
  
    - name: Setup NuGet
      uses: NuGet/setup-nuget@v1.0.5

    - name: Restore NuGet packages
      run: nuget restore

    - name: Publish to folder
      run: msbuild /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="\published\"

    - name: Deploy to Azure Web App
      uses: azure/webapps-deploy@v2
      with:
        app-name: 'myname'
        slot-name: 'production'
        publish-profile: ${{ ... }}
        package: \published\

Specifically, the error occurs during "Publish to folder" step.

1 Answers

Found the solution to my problem. Since I was using multi project solution, I had to modify msbuild command and specify to build my startup project. Now my publish to folder step looks something like this:

 - name: Publish to folder
      run: msbuild src\myproj\myproj.csproj ...
Related