Search code examples
c#githubazure-web-app-servicegithub-actions.net-6.0

A .Net 6 C# Azure web app shows HTTP Error 500.31 - ANCM Failed to Find Native Dependencies after deploying via github ci/cd


I have an Azure Web App that was running fine until recently. However, lately, I am getting the following error:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://app-wil-payroll-dev.scm.azurewebsites.net/detectors?type=tools&name=eventviewer and https://go.microsoft.com/fwlink/?LinkID=2028526

However, if I publish directly from Visual Studio, then the app works fine! The issue only happens when I push it via github actions.

The web app properties:

  1. Runs on .Net 6,
  2. 32 bit Windows,
  3. C#,
  4. Connected to a github ci/cd

The .yml file is standard .net yml that gets generated when github integration is turned on. No changes were made to the .yml file.

The only change that was made recently is the addition of a few test cases in XUnit.

Any thoughts?

I have tried the following:

  1. Changing the .yml file to use @v2 of actions/setup-dotnet instead of @v1.

Solution

  • It turns out, it was an easy fix! The Solution (.sln) file's "Release" config contained the XUnit Test project to be built. Excluding the test project from the solution and committing the .sln file to github, fixed the issue.

    Release Config in Visual Studio

    In the azure Kudo console, when I looked into the output directory of the web-app resource, I noticed the xunit dll files are gone and only the proper app dlls are present. I think the xunit stuff was causing an issue and having them not present in the output directory solved it.

    Please note, I did not have to change anything in the .yml file.

    Probably when I added the unit test project, it automatically got added in the build configuration (and so the publish stopped working after that).

    This also explains why it was working when deploying from visual studio.

    In the visual studio, I was publishing only the specific project (the web app project) and not the unit test project. So the output directory did not contain any files from the test project and subsequently the web-app ran fine on azure.

    Hope that helps.