Mahbubur Rahman Manik
Mahbubur Rahman Manik

Reputation: 5161

Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2

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.

Upvotes: 19

Views: 10939

Answers (2)

0xced
0xced

Reputation: 26583

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>

Upvotes: 4

Joey Cai
Joey Cai

Reputation: 20127

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.

Upvotes: 33

Related Questions