Home > Mobile >  How to deploy ASP.Net Web API (.Net 4.7.2) using github action
How to deploy ASP.Net Web API (.Net 4.7.2) using github action

Time:08-15

I have a ASP.Net Web API that's currently running on .Net 4.7.2 and I want to use Github action for continuous integration but i have no idea how to create a build artifact and upload it to azure. Below you can see my current steps and I have the restore and build process setup, All i need right now is to publish it to azure.

steps:
  - uses: actions/checkout@v3

  - name: setup-msbuild
    uses: microsoft/setup-msbuild@v1
  
  - name: Setup Nuget.exe for use with actions
    uses: Nuget/[email protected]
        
  - name: Restore Nuget Packages
    run: nuget restore solution.sln
    
  - name: Build Solution
    run: msbuild solution.sln

CodePudding user response:

I was able to figure it out, adding this additional parameter in msbuild solution.sln

/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:DeleteExistingFiles=True /p:platform="Any CPU" /p:configuration="Release" /p:PublishUrl="../_build"

will create the build artifacts then calling this action

  - name: Upload Artifact
    uses: actions/[email protected]
    with:
      name: Bundle
      path: "./_build"

to upload the build artifact then adding the azure web-app deploy

  - name: 'Deploy to Azure Web App'
    uses: azure/webapps-deploy@v2
    with:
      app-name: 'web-app'
      publish-profile: ${{ secrets.PUBLISH_PROFILE }}
      package: ./_build

will automatically deploy it to azure.

  • Related