BuildTasks.Csc task could not be loaded from the assembly?

asp.netasp.net MvcEntity FrameworkAzureAzure Devops

asp.net Problem Overview


I feel guilty asking a question like this around here, but I'm at a loss and would appreciate some help.

A proof-of-concept like web application was built on one PC and put up on a repo to download on another PC at a different location. There was originally an auto-build feature set up where Azure would build and publish automatically on check-in, but that was removed. Things were working on both ends until one side included a bulk of excluded changes. Now I'm seeing the following error:

> The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be
> loaded from the assembly > ...\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. > Could not load file or assembly > 'file:///...\packages\Microsoft.Net.Compilers.1.0.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll' > or one of its dependencies. The system cannot find the file specified. > 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.

Does anyone have any suggestions on where to begin looking for the issue?

asp.net Solutions


Solution 1 - asp.net

It turns out that NuGet packages were committed to the repository and breaking everything. Deleting the project\project\packages directory from the repo solved all build problems since NuGet fetches the packages automatically on build.

Solution 2 - asp.net

I got this error when I created a new branch for my project.

It drove me crazy for an hour. I tried most of the suggestions over the internet including the accepted answer to this question.

I then closed the project, opened it again, cleaned it and the error is gone. So this means this could be cache issue.

Anyways, just wanted to share.

Solution 3 - asp.net

I too tried the top answer with no luck so deleted the contents of my bin and packages dir, closed and re-opened VS and everything fine now.

Solution 4 - asp.net

I have tried all solutions described before, but none worked.

What solved it for me, was to update the Microsoft.Net.Compilers from the NuGet Package Manager

Solution 5 - asp.net

  • Right-click on your solution.
  • Go to Manage Nuget Packages.
  • Search for Microsoft.Net.Compilers.
  • Install or update on dependent projects as necessary.

Solution 6 - asp.net

Re-build, clean solution and restart Visual Studio worked for me.

Solution 7 - asp.net

Deleting the package and cleaning the solution solved it for me.

Solution 8 - asp.net

Deleting these three directories solves the problem.

  • /packages
  • /bin
  • /obj

NOTE: delete both /bin and /obj from all projects included in the solution (including Test projects).

Solution 9 - asp.net

Use the below step:

  1. Delete the package folder.
  2. close the visual studio.
  3. open the project and rebuild the project.

Solution 10 - asp.net

Problem hides on TFS, you need to remove folder TestProject...\packages from TFS, check in, delete it from your local dir and build again. Worked!

Solution 11 - asp.net

I delete all from packages folder and rebuild solution. It's worked for me.

Solution 12 - asp.net

In my case: this works for me.

It turns out my teammate had already started looking into Windows 10 development and had Microsoft Build Tools 2015 installed on his machine.

I installed the software from https://www.microsoft.com/en-us/download/details.aspx?id=48159 and the problem was solved.

Solution 13 - asp.net

In my case, the solution was:

Use Windows Explorer and navigate to the offending path: C:\MyApplication\Code\Main\ABCProject\ABCProject.UI\Bin

Right click on bin folder > select properties > Uncheck ReadOnly.

Solution 14 - asp.net

In my case, the solution was:

  1. Right Click on Solution.
  2. Go to Manage Nuget Packages for this Solution.
  3. Search for Microsoft.CodeDom.Providers.DotNetCompilerPlatform.
  4. Uninstall the searched Package.
  5. Restart the Visual Studio.

Solution 15 - asp.net

I just tried this on a clean install of a Windows 10 machine and the issue for me ended up being that I didn't have the .NET 3.5 framework installed. This stackoverflow question helps explain why.

https://stackoverflow.com/questions/35132076/cannot-build-wix-project-on-windows-10

Solution 16 - asp.net

Right Click on Solution. Go to Manage Nuget Packages for this Solution. Search forMicrosoft.Net.Compilers on Browse Section.

Solution 17 - asp.net

Deleting the bin folder worked for me

Solution 18 - asp.net

In vs2017 community there appeared a new item in the "build" menu. It disappeared after I used it and was called something like "Optimise project build packages". I clicked it and it fixed everything, just restart etc. I did it on two machines.

What it did was removed Microsoft.net.compilers 2.10.0 and replaced with Microsoft.CodeDom.Providers.DotNetCompilerPlatform 2.0.1

So there you go - more automagic...

Solution 19 - asp.net

My project was built with .Net Core 2.2 but I had .Net core 3.0 preview installed. I uninstalled .Net Core 3.0 from my system and went through all my class libraries, removing Microsoft.Net.Compilers 3.0, then rebuilt and it worked.

Solution 20 - asp.net

I moved my solution from one drive to another, and one of the files could not be copied because "in used", for which I click ignored, producing the error described in this post. Copying the missing file manually fixed it.

file: Microsoft.Build.Tasks.CodeAnalysis.dll Destination directory: packages\Microsoft.Net.Compilers.2.1.0\tools

Solution 21 - asp.net

For me I was trying to open a MVC5 project in VS 2013 and I was getting this error, Opened it in VS 2017 and up it worked just fine.

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
QuestionSofterwareView Question on Stackoverflow
Solution 1 - asp.netSofterwareView Answer on Stackoverflow
Solution 2 - asp.netbazingaView Answer on Stackoverflow
Solution 3 - asp.netStephen GarsideView Answer on Stackoverflow
Solution 4 - asp.netCătălin RădoiView Answer on Stackoverflow
Solution 5 - asp.nettikaView Answer on Stackoverflow
Solution 6 - asp.netRohitView Answer on Stackoverflow
Solution 7 - asp.netuser3085805View Answer on Stackoverflow
Solution 8 - asp.netFelipe RomeroView Answer on Stackoverflow
Solution 9 - asp.netSumant SinghView Answer on Stackoverflow
Solution 10 - asp.netDiSaSteRView Answer on Stackoverflow
Solution 11 - asp.netN.RybchenkoView Answer on Stackoverflow
Solution 12 - asp.netAjmalView Answer on Stackoverflow
Solution 13 - asp.netTerry HView Answer on Stackoverflow
Solution 14 - asp.netLitisqe KumarView Answer on Stackoverflow
Solution 15 - asp.netuser2197446View Answer on Stackoverflow
Solution 16 - asp.netravula sandeepView Answer on Stackoverflow
Solution 17 - asp.netamar beeharry panrayView Answer on Stackoverflow
Solution 18 - asp.netCraigView Answer on Stackoverflow
Solution 19 - asp.netemekaView Answer on Stackoverflow
Solution 20 - asp.netgharelView Answer on Stackoverflow
Solution 21 - asp.netwhiskView Answer on Stackoverflow