I am trying to publish asp.net core 2.1 application to azure app service through visual studio and getting following exception. How to resolve this?
C:\Program Files\dotnet\sdk\2.2.108\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5):
Error MSB4018: The "TransformWebConfig" task failed unexpectedly.
System.Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2.
at Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.TransformAspNetCore(XElement aspNetCoreElement, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel)
at Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.Transform(XDocument webConfig, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel, String environmentName)
at Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
Solution:
Removing <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
from .csproj
resolved my issue.
visual studio - Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2 - Stack Overflow Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2 Bookmark this question.
The in-process hosting model isn't supported for ASP.NET Core apps that target the .NET Framework. The value of <AspNetCoreHostingModel> is case insensitive, so inprocess and outofprocess are valid values.
ASP.NET Core Module. The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to either: Host an ASP.NET Core app inside of the IIS worker process (w3wp.exe), called the in-process hosting model. Forward web requests to a backend ASP.NET Core app running the Kestrel server, called the out-of-process hosting model.
That V2 module is the 5.0. The installer for 5.0 installs the AspNetCoreModuleV2 and that installer does not give you an install options to place it in system32 like the other modules. I'm glad that he said that Change AspNetCoreModuleV2 to AspNetCoreModule inside web.config is not recommended and is just a workaround.
Add this line to your web.config:
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
Or add this property in .csproj
file.
<AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>
Update:
Removing <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
from .csproj
resolve my issue.
To get rid of this error, I disabled the web config transform by setting the IsTransformWebConfigDisabled property to true
in my csproj file. A web.config file is useless when using Kestrel on macOS anyway, not sure why the build system tries to transform a non-existent web.config file on macOS in the first place.
<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With