Share via


Error message: The task factory "CodeTaskFactory" could not be loaded from the assembly

Question

Friday, March 10, 2017 3:06 PM | 1 vote

Hi,

I just installed VS2015 professional. When I tried to compile a C# project, I got the following error message:

Error                      The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v14.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v14.0.dll' or one of its dependencies. The system cannot find the file specified.

I searched internet and couldn't find a working resolution.

I'd like to know how to get Microsoft.Build.Tasks.v14.0.dll and how to install it.

Thanks.

Peiqing

All replies (3)

Monday, March 13, 2017 5:58 AM

Hi Peiqing,

As you said that you use the VS2015, whether this project was created in previous old VS version.

How did you build your app? Do you use the TFS or MSbuild in command line?

>>The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v14.0.dll". Could not load file or assembly 'file:///C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Build.Tasks.v14.0.dll' or one of its dependencies. The system cannot find the file specified.

Please check that whether it is related to the targets file AssemblyFile="$(ls-msbuildtasks-path)">
Reference:

https://github.com/ligershark/publish-ignore/issues/12

http://stackoverflow.com/questions/20661943/build-on-tfs-2013-failed-but-okay-locally

In addition, the MSbuild path has been changed from the VS2013.

Best Regards,

Jack

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact [email protected].


Sunday, June 24, 2018 11:01 AM | 2 votes

The above answer is like most MS answers uselsess. There are 2 things you can try:

- 1st: update NuGet packages for your project. The resoning behind it is that probably one of your NuGet packages is using pre MS-BUILD 15 way of referencing the CodeTaskFactory, this has changed in VS15. 

if it fails:

- 2nd: check your project / build files for occurrences of UsingTask referencing Microsoft.Build.Tasks.vxx.Something where Something is some version dependent and change it to Microsoft.Build.Tasks.Core.dll

If it fails:

- 3rd: check your project file (.csproj) for 

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns ...blah...blah...blah...>

and try replacing "12.0" to something else like 4.0 

custom msbuild code or something

If it fails:

- 4th: try to disable different references in your project to try & locate the packet causing the error - and contact it's authors to change the way they reference CodeTaskFactory


Tuesday, October 15, 2019 8:39 PM

This worked for me.  I think this was the first time I got a straight/useful answer out of msdn

* * *

I was using VS2017 and the line was 

<Project ToolsVersion="14.0"

which I changed (for no particular reason) to

<Project ToolsVersion="12.0"

And my error went away. 

This happened after I added a NuGet package that was last updated January, 2017 (libsoldium-net).  Even after I removed the package the error remained.  

I'm just experimenting with how to decrypt stuff sent to a C# app from Php, so I'm not too concerned what this all mean.

This is why I'm a Php programmer

I hate Microsoft