Reputation: 1175
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.
Upvotes: 57
Views: 47531
Reputation: 337
I fixed this by renaming C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.Targets
to something MSBuild and VS 2015 couldn't find
Weird that the bad AssemblyTasks reference was in a file outside the repo I was compiling, that I should not have to edit. But I have been working with several different versions of Visual Studio, I'm not surprised one got its wires crossed.
Upvotes: 1
Reputation: 11
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
Upvotes: 1
Reputation: 24405
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.
Upvotes: 0
Reputation: 257
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
Upvotes: 0
Reputation: 291
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
Upvotes: 9
Reputation: 531
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')" />
Upvotes: 2
Reputation: 612
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
Upvotes: 26
Reputation: 2252
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
Upvotes: 1
Reputation: 126
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">
Upvotes: 4
Reputation: 91
In my case, I removed "ls.pubignore.wpp.targets" file from root. and It removed the error. :)
Upvotes: 1
Reputation: 13546
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.
Upvotes: 6
Reputation: 1417
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
Upvotes: 60
Reputation: 5506
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!
Upvotes: 21