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

    Question

  • 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

    Friday, March 10, 2017 3:06 PM

All replies

  • 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 MSDNFSF@microsoft.com.

    Monday, March 13, 2017 5:58 AM
    Moderator
  • 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


    • Edited by Damago1 Sunday, June 24, 2018 11:02 AM typo error
    Sunday, June 24, 2018 11:01 AM