Reputation: 678
I get
'The "TransformWebConfig" task failed unexpectedly. System.Exception: The acceptable value for AspNetCoreModuleHostingModel property is either "InProcess" or "OutOfProcess".'
error while publishing an ASP.NET Core 2.2.0 application (actually it is the included sample application) for win-x64 environment. Both Visual Studio 2017 and 2019 gives the same error. I am working on Windows 10. What should I do to solve this? Last part of publish Output is:
c:\users\engin\source\repos\NetCoreWebApplication2\NetCoreWebApplication2\obj\Release\netcoreapp2.2\win-x64\PubTmp\Out\
C:\Program Files\dotnet\sdk\2.2.200-preview-009648\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): Hata MSB4018: "TransformWebConfig" görevi beklenmedik biçimde başarısız oldu.
System.Exception: The acceptable value for AspNetCoreModuleHostingModel
property is either "InProcess" or "OutOfProcess".
konum: Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.TransformAspNetCore(XElement aspNetCoreElement, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel)
konum: Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.Transform(XDocument webConfig, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel, String environmentName)
konum: Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute()
konum: Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
konum: Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2 Derleme başarısız oldu. Daha fazla ayrıntı için çıktı penceresini denetleyin.
========== Oluşturma: 1 başarılı, 0 başarısız, 0 güncel, 0 atlandı ==========
========== Yayın: 0 başarılı, 1 başarısız, 0 atlandı ==========
Upvotes: 46
Views: 30533
Reputation: 316
After updating from 17.8.7 to 17.9.3 I had to change web.config from InProcess to inprocess.
Upvotes: 0
Reputation: 4547
I had a project in TFS
, due to some issues, the TFS
went down and when I made it go online again, it failed to publish the project, while the debugging worked fine. It caused the error (The TransformWebConfig task failed unexpectedly
).
After checking the output window, it seemed some files were not accessible to visual studio, or were protected. So, it was because of the TFS
, all or most of the files in the project were set as Read-Only
which is why Visual Studio couldn't transform those files.
Removing the Read-Only
flag from the project fixed the publishing problem.
Upvotes: 3
Reputation: 1
If you are upgrading your .net core version from 3.1 to higher framework, please check web.config aspNetCore node
The attribute hostingModel
should be inprocess
(all small case) vs InProcess
in .netcore 3.1 framework
This change worked for me and able to publish my project.
Upvotes: 0
Reputation: 4547
For me, there was a permission issue which is why, while publishing, a transformation task was running on web.config
file. That file did not had access for normal user.
Closing Visual Studio and running it as Administrator then publishing the project worked for me or you can try on setting the correct permissions for the problematic file.
After successfully publishing the project once with administrator privileges, visual studio started working with normal users as well (weird though but good).
UPDATE:
Stumbled into the same problem again, and this time it was not resolved by the above solution, I had to check back the project directory and some of the files were marked Read-Only
had to change it to get it working. I suppose this is a problem with the TFS
which gets the files and sets them as Read-Only
.
Upvotes: 3
Reputation: 93
Adding this to the .csproj file did it for me:
<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
Upvotes: 0
Reputation: 371
find the project file (.csproj) and update this code
<AspNetCoreHostingModel>OutProcess</AspNetCoreHostingModel>
to this
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Upvotes: 0
Reputation: 2882
I would suggest disabling web.config transforms altogether. In an ASP.Net Core project you probably do not need to transform web.configs since supplying environment variables is handled by convention with appsettings.[Environment].json
files.
From the docs at https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2:
To prevent the Web SDK from transforming the web.config file, use the
<IsTransformWebConfigDisabled>
property in the.csproj
file:
<PropertyGroup>
<IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
Upvotes: 69
Reputation: 309
Just add this line to your web.config file
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
Upvotes: 14
Reputation: 111
My .NET Core 2.2 application build was failing on Jenkins but it was working fine on local machine. Error: error MSB4018: The "TransformWebConfig" task failed unexpectedly.
Fix: Removed below line from .csproj file
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Upvotes: 1
Reputation: 514
The answer @Barış Bar provided is working but can cause future errors. There is a bug about UpperCases. Just change InProcess
in csproj
file with lowercase
<AspNetCoreHostingModel>inprocess</AspNetCoreHostingModel>
It is said that the bug will be corrected in VS 2019.
Upvotes: 16
Reputation: 869
Had the same issue on .net core 2.2.104. Update the section to this:
<AspNetCoreHostingModelV2>InProcess</AspNetCoreHostingModelV2>
Note the V2 addition.
Upvotes: 35
Reputation: 572
I had the same problem and found the solution
In the csproj
file, find following line and delete.
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Upvotes: 55