How to deploy a .NET Core solution with multiple web apps to Azure using Github Actions

Owen 11 Reputation points
2021-06-20T17:05:44.227+00:00

I've got a .NET Core 3.1 solution with 10 projects, 4 of them are web apps.

I hooked up my Azure App Service to GitHub so that every time I publish or click 'Sync' under 'Deployment Center', my code in GitHub will be transferred to my App Service.

According to this document, Azure takes the first web app it comes across and uses it as the default: https://learn.microsoft.com/en-gb/azure/app-service/configure-language-dotnetcore?pivots=platform-linux#deploy-multi-project-solutions

I did exactly what the document said and set an Application Setting in my App Service Configuration to:
Name: PROJECT
Value: projectName/projectName.csproj

This question from 5 years ago is about the same problem, but the solution says to do what the above article says, only exclude the projectName.csproj: https://stackoverflow.com/questions/36270956/azure-deployment-source-choose-startup-project-to-build

Both solutions give me the same kind of error under GitHub Actions:
Error: Could not find a part of the path 'C:\local\Temp\zipdeploy\extracted\projectName'

I've gone into the above 'extracted' directory, and it can't find 'projectName' because the file structure is pretty much flat and all my projects are in there as DLLs and EXEs. Basically the folder structure isn't the same as my local and projects are no longer in their own folders.

How can I do this?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,398 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,923 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Owen 11 Reputation points
    2021-06-21T14:34:33.457+00:00

    Figured out the answer by creating a yaml from Visual Studio publish and comparing it with GitHub's yaml.

    This is a section of the workflow that Azure creates for GitHub:

    - name: Build with dotnet
          run: dotnet build --configuration Release
    - name: dotnet publish
          run: dotnet publish -c Release -o ${<!-- -->{env.DOTNET_ROOT}}/myapp
    

    I added the project name after build and publish:

    - name: Build with dotnet
          run: dotnet build PROJECT_NAME --configuration Release
    - name: dotnet publish
          run: dotnet publish PROJECT_NAME -c Release -o ${<!-- -->{env.DOTNET_ROOT}}/myapp
    
    1 person found this answer helpful.