Running on VSTS an core sln I got: Error MSB4018: The "TransformWebConfig" task failed unexpectedly

by Zinov   Last Updated June 11, 2019 21:26 PM

I am trying to create a build definition for an core application. My project compiles on the Visual Studio and also with MSBuild. When I am trying to run the solution on Azure to compile is where it fails to show the message below:

C:\Program Files\dotnet\sdk\2.2.105\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.<ExecuteInstantiatedTask>d__26.MoveNext()
Process 'msbuild.exe' exited with code '1'.

The weird thing is that I have currently installed on my computer the SDK 2.2.300 with Runtime 2.2.5, but when I am running the build definition in the VSTS it seems that the SDK it is using is 2.2.105. My initial thought was that the VSTS agent didn't have the correct version, and it was running with 2.2.105. After running a self-hosted agent, the error is the same.

Seeing online the details on the VSTS agents, I found that the highest .NetCore dependency they have installed is SDK 2.2.105.

enter image description here

Let's say that you want to choose one of the agents you have on the pool, you will only get 2.2.105

Picking one of them and going under their details, you can read

.NET Core
The following runtimes and SDKs are installed:


PATH: contains location of dotnet.exe

2.2.105 C:\Program Files\dotnet\sdk\2.2.105
2.2.104 C:\Program Files\dotnet\sdk\2.2.104
2.2.103 C:\Program Files\dotnet\sdk\2.2.103
2.2.102 C:\Program Files\dotnet\sdk\2.2.102

You have a couple of ways to solve it: 1-Wait for Microsoft to update their online agents 2-Create an on-prem agent(self-hosted agent), running on your localhost where you have all the dependencies installed 3- is to add a step that installs the SDK as part of the agent's tasks, but unfortunately, I couldn't make it work, but that should be the 3rd step.

enter image description here

Answers 1

As you see in Azure Pipelines VM images for Microsoft-hosted CI/CD, the highest .NET Core version which has been installed in hosted agent is SDK 2.2.105 with Runtime 2.2.3. But the version you installed to build project is .NET Core SDK 2.2.300 with Runtime 2.2.5. That's why you got that error message.

You can use task to install the matched version to support this build. Add extension .NET Core Global Tool Installer first, and use dotnet version 2.*(preview) task to install .NET Core SDK 2.2.300 with Runtime 2.2.5.

Merlin Liang - MSFT
Merlin Liang - MSFT
June 18, 2019 11:24 AM

Related Questions

How to use secret task variables with npm tasks

Updated July 10, 2019 23:26 PM

Export tests results from Azure DevOps

Updated September 02, 2019 06:26 AM