jeffkl / RoslynCodeTaskFactory

An MSBuild CodeTaskFactory that uses Roslyn compiler for cross platform compatibility
MIT License
26 stars 3 forks source link

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

Open niyatidoshi opened 4 years ago

niyatidoshi commented 4 years ago

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:

Could you please guide me how to resolve the error?

Thanks, Niyati

jeffkl commented 4 years ago

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.