2

I am trying to create a build definition for an asp.net 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. Going under agent's details, you can read

.NET Core
The following runtimes and SDKs are installed:

Environment:

PATH: contains location of dotnet.exe
SDK:

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

I was trying to troubleshoot on this way:

  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. try to add a step that installs the SDK as part of the agent's tasks(see the image below), but unfortunately, I couldn't make it work

Any thoughts?

enter image description here

Zinov
  • 3,817
  • 5
  • 36
  • 70
  • You must have something wrong initially. ASP.NET Core 2.2 and later do not support web.config at all. Why do you insist to use web.config on ASP.NET Core 2.2+? – Eriawan Kusumawardhono Jun 11 '19 at 08:22
  • I do not have webconfigs – Zinov Jun 11 '19 at 11:10
  • Ok. Looking at the build error, you might be having incorrect .NET TFM. Are you sure _all of your projects_ have the correct TFM of .NET Core 2.2 SDK, in the solution? And you should add dotnet tool installer task first, before doing the build. – Eriawan Kusumawardhono Jun 11 '19 at 11:16
  • 1
    That color contrast of the error message is illegible for me. It's also illegible to search engines, meaning that anyone else searching for terms in this error message will not find this question. Please reproduce all text relevant to your question in text form, not as images. – spender Jun 11 '19 at 14:45
  • @spender when you click it, you should have a good resolution for the image. – Zinov Jun 11 '19 at 14:48
  • @zinov That doesn't address the search engine issue. In addition, some people are color blind and have trouble reading dark red text on a black background. – Daniel Mann Jun 11 '19 at 14:54
  • @Zinov SO is a *shared* repository of knowlege. It is well maintained and should be easily searchable. People contribute information not only because it is useful to one person, but that it might be useful to others. This is why I am asking you to reproduce all information in text form. For the search engines. Also, my eyes definitely are not as good as yours. I literally can't read your error message, no matter what size it is. – spender Jun 11 '19 at 14:56
  • 1
    @spender, good point, thanks for your comments about the search engine, I just passed it, sorry, I just updated the question with the original text – Zinov Jun 11 '19 at 15:18

2 Answers2

1

If you don't want to use in-process hosting, delete the "AspNetCoreHostingModel" element from your .csproj:

   <PropertyGroup>
     <TargetFramework>netcoreapp2.1</TargetFramework>
     <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
   </PropertyGroup>
Murray
  • 1,948
  • 1
  • 12
  • 18
0

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.

Mengdi Liang
  • 17,577
  • 2
  • 28
  • 35