The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly

Bryan picture Bryan · Oct 15, 2015 · Viewed 36.3k times · Source

I have a project that I have on TFS online. When Im trying to build the project, I get the following error:

Severity Code Description Project File Line Error The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'file:///C:\Users\Bryan\Source\Workspaces\TestProject\ContosoUniversity\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll' or one of its dependencies. Could not find the file. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. ContosoUniversity

Has this something to do with that Azure don't support ASP.NET 4.6?

Answer

Salman Lone picture Salman Lone · Nov 22, 2016

Here was the fix for me. Using Nuget Package Manager, remove these two packages if referenced:

Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers

After that, run a rebuild. This ensured that the build was not trying to use a specific build exe. Click here for the Diff against previous revision