I am attempting to deploy a simply Web Api App to Azure to help me familiarise myself with Azure services and Github Actions for deployment. Below are the steps I have undertaken
1 - Create a new .NET 7 Web Api App in Visual Studio. This creates a boilerplate Weatherforecast API app and runs as expected locally through VS. 2- Create a new github repository and publish my .sln file along with the project folder to this repository
In Azure :
Create new Web App service in my main resource group
During creation link to my github account and select the repository and main branch where my project folder and .sln file reside.
Now workflow file is created in the repository and deplyoment will initiate, but after a few minutes it fails with the error:
The "--output" option isn't supported when building a solution.
I cannot see how to disable this option, below if the workflow file:
name: Build and deploy ASP.Net Core app to Azure Web App - muzztest
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build --configuration Release
- name: dotnet publish
run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: .net-app
path: ${{env.DOTNET_ROOT}}/myapp
deploy:
runs-on: windows-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: .net-app
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'muzztest'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_4F1CE8C3BB3A4BA59C822347153C6D43 }}
package: .
What can I do to resolve the stumbling block above?
This is due to changes in the supported flags for .NET 7 when building solutions.
Instead of -o DIR or --output DIR you now need to use --property:PublishDir=DIR
Please see: https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/7.0/solution-level-output-no-longer-valid for further info. Especially the Recommended action section is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With