Note : Cet article a été publié à l’origine en 2016. Certaines étapes, commandes ou versions de logiciels ont pu changer. Consultez la documentation actuelle de .Net pour les informations les plus récentes.
If you’re encountering this issue, this troubleshooting guide will help you identify the root cause and apply the appropriate fix. This applies to .Net environments.
Resolved: The “Microsoft.CodeAnalysis.BuildTasks.Csc” task could not be loaded from the assembly
I recently have been working on an ASP.Net application and at some point I started to get build errors that although they were not stopping the build and allowed me to continue with the application’s execution, they were starting to get quite annoying. This is a sample of the error message that tormented me for ages but because it wasn’t a show stopper I left it there for almost a week:
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.
Thankfully the solution was a simple one. If you take a look at the file in reference it points you to a packages location. It turns out that NuGet packages were committed to the repository and are breaking everything. To resolve this, you simply need to delete that packages folder (usually under
The solution recap:
- Locate you project’s packages folder
- Delete the folder
- Rebuild your project
- You’re done!
Résumé
This guide covered the common causes and solutions for this .Net issue. If the problem persists, check the official documentation or system logs for additional diagnostic information.
Articles Connexes
- Entity Framework 4: Any way to know the plural form of an Entity Type?
- Entity Framework - Why can’t I see the child entities of my entity
- Enumeration: What are the different SharePoint permission levels and their enumeration values?
- Error 1 SQL03006: User: [ ] has an unresolved reference to Login [ ]