How do I fix HTTP Error 502.5 - Process Failure when hosting in IIS with dotnet core

13 May 2018

dotnet core IIS Just Coding

I received a new error today that I haven't received before when deploying dotnet core apps. It was as the title suggest a "HTTP Error 502.5 - Process Failure" error


None of the suggestions had any affect and hours of Googling also didn't help either until eventually I came across a solution that worked

The Solution

I eventually found a solution on the aspnet / Hosting repo on GitHub  on issue number #1234 (funny enough it feels made up but isn't). jdownie posts the following solution



Although that solution worked for me it wasn't good enough. The problem here is that I deploy everything through TFS or VSTS so I couldn't just manually set the value.

My Solution

Although hacky, my solution works for me. similar to how the solution above worked for jdownie Smile. I'm lucky enough to be able to place an agent on my web server so I can run this method otherwise unzipping, hard coding the value from the build server and zipping up the publish package can also work.

Basically what I have done is after I web deploy I have a final phase which checks the machine Paths environment variable and sets the processPath to the first path it finds that contains dotnet.exe in it



Now on every deploy I have a running site that is guaranteed to have a valid dotnet.exe value


and I guess more importantly a running site Smile with tongue out



dotet core although getting mature is not quite there in all aspects and you are going to hit some issues with it that you wouldn't expect.

The great thing about this is the support from the community and Microsoft is brilliant and the decision to go dotnet core would not be a bad one Open-mouthed smile.

It also appears that something was wrong on the server which is why dotnet.exe wasn't being picked up even after a reboot but that's a investigation for another day