RoslynCodeTaskFactory icon indicating copy to clipboard operation
RoslynCodeTaskFactory copied to clipboard

error MSB4801: The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild

Open niyatidoshi opened this issue 4 years ago • 1 comments

Hi Guys,

I'm facing below error when I run command "dotnet test.\SampleAPITest.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput="./TestResults/Coverage/" to run test cases.

D:\Projects\VSTS\SampleAPI\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): error MSB4801: The task factory "CodeTaskFactory" is not supported on the .NET Core version of MSBuild. [D:\Projects\VSTS\SampleAPI\SampleAPI\SampleAPI.csproj]

D:\Projects\VSTS\SampleAPI\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files\dotnet\sdk\3.1.300\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property. [D:\Projects\VSTS\SampleAPI\SampleAPI\SampleAPI.csproj]

Below are the project details:

Projects are based on .Net Framework 4.7.2

  1. SampleAPI (WebAPI)
  2. SampleAPI.Test (Test Project) Project contains reference of "SampleAPI" - to write the test cases of Controller.

Other details:

  • To generate code coverage and reports, I've added reference of Coverlet in the test project.
  • Added MSBuild.Microsoft.VisualStudio.Web.targets in WebAPI project.
  • Already added "RoslynCodeTaskFactory" 2.0.7

Could you please guide me how to resolve the error?

Thanks, Niyati

niyatidoshi avatar Jun 30 '20 11:06 niyatidoshi

It looks like the package Microsoft.CodeDom.Providers.DotNetCompilerPlatform is using CodeTaskFactory not RoslynCodeTaskFactory. Target owners need to update their targets to use the new task.

jeffkl avatar Jul 01 '20 18:07 jeffkl