56
votes

When attempting to build in visual studio 2015, the following file is missing? This project was previously being built in VS2013.

Severity Code Description Project File Line 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.

12
Try removing and adding the references again may help you.Hossein Narimani Rad
Update NuGet packages helped meTimeless
Make sure you have selected Windows Workflow Foundation in the VS Individual Components, That's how i fixed the issue. See below same, johnlouros.com/blog/…Safi

12 Answers

59
votes

The assembly has been renamed. Change on the CodeTaskFactory MSBuild Task the AssemblyFile parameter to...(in your error there should be a targets file name where this task resides)

AssemblyFile="C:\Program Files (x86)\MSBuild\14.0\Bin\Microsoft.Build.Tasks.Core.dll"

Chances are someone tried to be clever and use an MSBuild property like this..(which doesn't work for MSBuild 14 but would for 12)...

AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v$(MSBuildToolsVersion).dll"

Just fyi...There are some others as well such as Microsoft.Build.Utilities.v12.0.dll has been renamed to Microsoft.Build.Utilities.Core.dll

26
votes

What helped me with Visual Studio 2017 is to copy Microsoft.Build.Tasks.Core.dll and rename it to Microsoft.Build.Tasks.v15.0.dll build.tasks.v15.0.dll

21
votes

In my case that was a problem of SFML.NET nuget package.

It depended upon outdated Nuget Baseclass.Contrib.Nuget.Output component, which was the reason why build failed.

After i manually updated to .Net 4.6, deleted all nuget staff from project file and deleted its files from project and readded all dependencies again version of Baseclass.Contrib.Nuget.Output was changed and viola!

9
votes

First time I restart visual studio, worked for me

Second time I got this error again and I did update:

Install-Package Baseclass.Contrib.Nuget.Output -Version 2.2.0-xbuild02

6
votes

It was enough for me to just restart Visual Studio.

I suspect that I had earlier killed all my MSBuild.exe processes doing something else and that not having any MSBuild.exe processes causes the error.

4
votes

Following on from Gary's answer I parameterized this as follows:

<Choose>
  <When Condition="'$(MSBuildToolsVersion)'=='14.0'">
    <PropertyGroup>
      <TasksAssemblyName>Microsoft.Build.Tasks.Core</TasksAssemblyName>
    </PropertyGroup>
  </When>
  <Otherwise>
    <PropertyGroup>
      <TasksAssemblyName>Microsoft.Build.Tasks.v$(MSBuildToolsVersion)</TasksAssemblyName>
    </PropertyGroup>
  </Otherwise>
</Choose>
<UsingTask TaskName="SecondsSinceEpoch" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\$(TasksAssemblyName).dll">
2
votes

My solution: removing two rows from the "*.csproj" file:

<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
1
votes

In my case, I removed "ls.pubignore.wpp.targets" file from root. and It removed the error. :)

1
votes

I had the same issue, in my case I updated some of the packages from NuGet package manager in VS2015, then tried to open the same solution in vs2013 in another machine where vs2015 was not installed.

Installing Microsoft Build Tools 2015 has resolved the error. That adds Microsoft.Build.Utilities.Core.dll to the GAC, which I think is what makes it work.

https://www.microsoft.com/en-in/download/details.aspx?id=48159

0
votes

For Visual Studio 2017 this is what worked for me, it's a mix of two provided solutions. Neither worked on their own so this is why I'm submitting this as a new answer.

In the file C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\v15.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets

Replace AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"> with AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">

And then copy the file C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Build.Tasks.Core.dll in the same folder with the name Microsoft.Build.Tasks.v15.0.dll

0
votes

For me I was converting from building our solution using msbuild to using dotnet build. Updating from codedom 2.0.1 -> 3.6.0 allowed the solution to build.

0
votes

Update the "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" from nuget packages and it resolves my error and this is the best solution ,after a multiple try i found out a solution

enter image description here