Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 311
Bryan Avatar asked Oct 15 '15 13:10

Bryan


4 Answers

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

like image 55
Salman Lone Avatar answered Nov 19 '22 11:11

Salman Lone


No, it is not related to Azure Web Apps doesn't support ASP.NET 4.6. Actually, you get this error message because NuGet packages are checked into version control.

So, you need to remove folder TestProject\ContosoUniversity\packages from TFS and build again. See: BuildTasks.Csc task could not be loaded from the assembly?

like image 42
Vicky - MSFT Avatar answered Nov 19 '22 11:11

Vicky - MSFT


I had the same problem sometime ago, to fix it:

  1. make sure your packages are not under source control
  2. Force restore all package, by deleting the package folder
  3. restart your visual studio
like image 8
pedrocha Avatar answered Nov 19 '22 12:11

pedrocha


In my case it got resolved by updating the below two Nuget packages to the latest version:

Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
like image 5
Koder101 Avatar answered Nov 19 '22 11:11

Koder101