1
votes

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/[email protected]
  
    - name: Setup NuGet
      uses: NuGet/[email protected]

    - 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
I use a different set of MSBuild parameters. /p:SkipInvalidConfigurations=true /p:DeployOnbuild=True /p:GenerateProjectSpecificOutputFolder=true /p:GenerateBuildInfoConfigFile=false /p:OutDir=$(Build.BinariesDirectory) /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false /p:langversion=latest That performs a file system publish to the $(Build.BinariesDirectory) directory (you'll want to replace that with whatever syntax GitHub Actions uses).mason
@GuiFalourd just double checked my solution and file system folder structure match. I think my solution builds fine, but fails on publish. Although I do have nested structure like /src/projectA and src/projectBivnrcomp
@mason thanks for the link, unfortunately it didn't help. I've tried to locally run MSBuild and confirmed that it builds and publishes solution without a problem. It seems that Azure/Kudu adds an additional step puts by putting the build results into a temporary folder.ivnrcomp

1 Answers

2
votes

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 ...