简体   繁体   中英

Deploying multi-project ASP.NET Core web app to Azure App Service using Github Actions

I'm setting up a new ASP.NET Core (version 3.1) web app. I have it hosted on Github and deployed to Azure App Service using Github Actions.

The deployment worked fine as long as I had a single project in the solution (the main ASP.NET Core project).

When I added a test project and set PROJECT=helloworld/helloworld.csproj in App Service configuration (as advised in documentation and also on a blog I found on the Internet), the deployment started to fail.

The Github Actions failure message says I should refer to logs for more details. I don't know where to get these logs.

The structure of my repository:

- helloworld (sln directory)
  - helloworld.sln
  - helloworld (main asp.net core project directory)
    - helloworld.csproj
  - tests
    - helloworld.tests (test project directory)
      - helloworld.tests.csproj

The Github Actions workflow definition is the basic one which was auto-generated when setting up the App Service:

...
- name: dotnet publish
  run: dotnet publish -c Release -o ${{env.DOTNET_ROOT}}/myapp

- name: Deploy to Azure Web App
  uses: azure/webapps-deploy@v1
  with:
    app-name: 'helloworld'
    slot-name: 'production'
    publish-profile: ${{ secrets.AzureAppService_PublishProfile_6941d41e13284fa890c1c34ffa8674e0 }}
    package: ${{env.DOTNET_ROOT}}/myapp 

The PROJECT setting can be used if you publish your sources to the AppService, and let it build and run the project. Your workflow is building and the code using Github Actions, so you just publish the compiled result. What you need to do is publish the desired project. Should look something like this:

- name: dotnet publish
  run: dotnet publish helloworld/helloworld.csproj -c Release -o ${{env.DOTNET_ROOT}}/myapp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM