It seems whenever I work on an ASP.NET Core website, I always seem to get the most unhelpful error when deploying to production:
HTTP Error 502.5 - Process Failure
I have no problem running the ASP.NET Core site whilst developing from within a local environment.
From past experience, the HTTP 502.5 error generally happens for the following reasons:
- The ASP.NET Core framework is not installed or your site is running the incorrect version.
- Website project incorrectly published.
- Potential configuration issue at code level.
Generally when you successfully publish a deployable version of your site, you'd expect it to just work. To get around the deployment woes, the solution is to modify your .csproj file by adding the following setting:
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
Once this setting has been added, you'll notice when your site is re-published a whole bunch of new DLL files are now present, forming part of all the dependencies a site requires. It's strange a normal publish does not do this already and what's even stranger is I have a different .NET Core site running without having to take this approach.
For any new .NET Core sites I work on, I will be using approach going forward.