The "TransformAppSettings" task failed unexpectedly

In my case, I edit the publish configuration and turned off the Database -> Use this connection at runtime. Then I could publish without this error, however, I had to manually edit the web.config and make the following changes.

modules="AspNetCorModuleV2"  had to become modules="AspNetCodeModule"

hostingModel="InProcess" had to become hostingModel="OutOfProcess" 

<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> had to become value="Production"

These changes were already in my own directories web.config, but they didn't seem to get propagated in the publish anymore.


I had this same error and was able to fix it by editing the .pubxml.user file.

When the error occurred, my publish settings didn't have the "Use this connection at runtime" selected, nor were any database migrations checked. But when I looked in the pubxml.user file and it turns out there was a reference to a non-existent database that wasn't showing up in the Publish Settings UI. I removed that and it solved the problem.