The “Microsoft.CodeAnalysis.BuildTasks.Csc” task could not be loaded

大憨熊 提交于 2019-12-07 04:38:26

问题


I'm trying to publish a newly created asp.net 4.6 web project to Azure web apps and receiving the following error:

remote: D:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(316,9): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.Csc" task could not be loaded from the assembly D:\home\site\repository\packages\Microsoft.Net.Compilers.1.0.0\build..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll. Could not load file or assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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. [D:\home\site\repository\WebApp\WebApp.csproj]

Everything builds fine via Visual Studio 2015 on my local machine. I thought Azure web apps were all set to support VS 2015 RTM upon release, but it would appear they do not have MSBuild 14.0 installed. Is there a work around or a roadmap for this problem?


回答1:


Azure Web Apps doesn't support ASP.NET 4.6 yet. It's on it's way though, so stay tuned.




回答2:


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

  1. Microsoft.CodeDom.Providers.DotNetCompilerPlatform
  2. 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




回答3:


In my case I have to edit my .csproj file and find below lines and delete them

<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />

Now everything is fine,



来源:https://stackoverflow.com/questions/31620168/the-microsoft-codeanalysis-buildtasks-csc-task-could-not-be-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!