Can't build in visual studio 2015 because 'Microsoft.Build.Tasks.v14.0.dll' cannot be found

C#MsbuildVisual Studio-2015

C# Problem Overview


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. Name>

C# Solutions


Solution 1 - C#

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

Solution 2 - C#

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

Solution 3 - C#

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!

Solution 4 - C#

First time I restart visual studio, worked for me

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

Solution 5 - C#

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.

Solution 6 - C#

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">

Solution 7 - C#

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')" />

Solution 8 - C#

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

Solution 9 - C#

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

Solution 10 - C#

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

Solution 11 - C#

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.

Solution 12 - C#

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChris SewellView Question on Stackoverflow
Solution 1 - C#Gary HowlettView Answer on Stackoverflow
Solution 2 - C#Alexander TrofimovView Answer on Stackoverflow
Solution 3 - C#Siarhei KuchukView Answer on Stackoverflow
Solution 4 - C#Houshang.KaramiView Answer on Stackoverflow
Solution 5 - C#Matthew LockView Answer on Stackoverflow
Solution 6 - C#AlastairView Answer on Stackoverflow
Solution 7 - C#Pavel SamoylenkoView Answer on Stackoverflow
Solution 8 - C#Nitesh KumarView Answer on Stackoverflow
Solution 9 - C#vinayak hegdeView Answer on Stackoverflow
Solution 10 - C#musicinmusicView Answer on Stackoverflow
Solution 11 - C#DLehView Answer on Stackoverflow
Solution 12 - C#sathish kumarView Answer on Stackoverflow