4

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 

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

2 Comments

This works great, thanks! Do you know where this is documented? I've been looking through both MS and GitHub docs on Actions and have been unable to find this.
Something like this: learn.microsoft.com/en-us/azure/app-service/…. It depends on the working directory and your solution structure, if you need to specify the project directly. This is more of a .NET Core build thing than having to do with Github Actions or Azure. learn.microsoft.com/en-us/dotnet/core/tools/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.