BuildTasks.Csc task could not be loaded from the a

2019-01-21 18:13发布

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?

16条回答
Juvenile、少年°
2楼-- · 2019-01-21 18:31

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.

查看更多
仙女界的扛把子
3楼-- · 2019-01-21 18:31

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.
查看更多
走好不送
4楼-- · 2019-01-21 18:34

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!

查看更多
我想做一个坏孩纸
5楼-- · 2019-01-21 18:36

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.

查看更多
一夜七次
6楼-- · 2019-01-21 18:40

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.

查看更多
太酷不给撩
7楼-- · 2019-01-21 18:42

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.

查看更多
登录 后发表回答